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 trialMatthew Floyd
7,413 PointsChallenge Grouping, Joining and Cleaning Up
I feel like I'm over looking something easy, or am I just grasping at straws with this code?
Group all reviews by "movie_id" and get the average "score" and alias it as "average".
SELECT AVG(score) AS average GROUP BY movie_id
3 Answers
Dave McFarland
Treehouse Teacheryou need to specify the table too:
SELECT AVG(score) AS average FROM reviews GROUP BY movie_id;
Gabi Udrescu
11,539 Pointswell... the copy paste did work for the first line, I managed to get through the second line, but the 3rd one seems impossible:
I'm trying to figure it out with the following command:
SELECT movies.title, IFNULL(AVG(reviews.score),0) AS average FROM reviews left OUTER JOIN movies on movies.id = reviews.movie_id GROUP BY movie_id having average < 2
but I bump into this error: Bummer! There's something wrong with your query.
I'm stuck with this. Can someone give me a hint on this one, please?
ryanjones6
13,797 PointsGood code examples here: https://teamtreehouse.com/community/code-challenge-3-2
Gabi Udrescu
11,539 PointsGabi Udrescu
11,539 PointsI must admit, I used the embarrassing method of copy pasting this solution, because the question is very ambiguous. I believe you should rewrite confusing questions as they probably frustrate everybody, even though they are a valuable lesson before engaging in solving real world problems.