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

Database Foundations 7.4 Question 3

Kind of stuck here, think anyone can help me tweak this to the right answer?

This is what I've got so far:

SELECT 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;

Thanks

2 Answers

Joseph Kato
Joseph Kato
35,340 Points

Hi Jeremy,

You're almost there; you're just missing the "display the movie 'title' before the 'average'" part, which would make it:

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;

I was stuck on the exact same thing. Turned out I was using a "." instead of a "," in the AVG function and the error returned wasn't meaningful. Thanks!