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 trial

Development Tools

Alexandru Olteanu
Alexandru Olteanu
17,522 Points

Grouping, 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

it 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
Alexandru Olteanu
17,522 Points

Oh, 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
Vernon Watson
8,854 Points
SELECT 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!