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 trialAlexandru Olteanu
17,522 PointsGrouping, joining and cleaning up challenge 2 of 3
Hello.
The question is: "Like before, group reviews by "movie_id", get the average "score" as "average" and filter out any averages over 2."
My query is: SELECT AVG(score) AS average FROM reviews GROUP BY movie_id HAVING average > 2;
Any idea why this won't work?
Thank you.
3 Answers
James Kennedy
20,755 Pointsit should be average < 2 because you are filtering out any averages over 2 and displaying only averages less than 2. I am now stuck on the next question of this same challenge though so any help would be appreciated if you get it
Alexandru Olteanu
17,522 PointsOh, how silly of me, then. It was quite simple.
I solved the third challenge and it goes like this:
SELECT title, IFNULL(AVG(score), 0) AS average FROM movies LEFT OUTER JOIN reviews ON movies.id = reviews.movie_id GROUP BY movie_id HAVING average < 2;
Vernon Watson
8,854 PointsSELECT movies.title, IFNULL(AVG(score),0) AS average
FROM reviews RIGHT OUTER JOIN movies
ON movies.id = reviews.movie_id
GROUP BY movie_id HAVING average < 2;
It was tough one!