Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialY B
14,136 PointsSQL challenge GROUP BY
I can't get past the group by challenge in the mySQL course. The question asks: Group all reviews by "movie_id" and get the average "score" and alias it as "average".
but my answer:
SELECT AVG(*) AS average FROM movies GROUP BY movie_id
doesn't seem to work?
5 Answers
Nicholas Morrow
7,362 PointsAhh, it's because the 'score' column is in the 'reviews' table.
Try:
SELECT AVG(score) AS average FROM reviews GROUP BY movie_id
Nicholas Morrow
7,362 PointsTry:
SELECT AVG(score) AS average FROM movies GROUP BY movie_id
Y B
14,136 PointsUnfortunately it still doesn't like that the error is:
SQL Error: Unknown column 'score' in 'field list'
Y B
14,136 Pointsah good spot thanks.
JoAnna Howell
7,191 PointsSELECT AVG(score) AS average FROM reviews GROUP BY movie_id;
don't forget the parentheses...
Saira Bottemuller
Courses Plus Student 1,749 PointsSaira Bottemuller
Courses Plus Student 1,749 PointsThank you so much, I was stuck on this one as well. At first I'd thought my input was exactly what you wrote here, but after reviewing it, I was trying to use SELECT movie_id, AVG(score) AS average FROM reviews GROUP BY movie_id; which is incorrect! So you can just directly select AVG(score) then?!