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 trialLuca Poggio
3,214 PointsSQL Calculating, Aggregating and Other Functions , code challenger ... what's wrong ?
I don't understand what I'm doing wrong in the last question of the code challenger within the section above.
This is the SQL I wrote
select title, IFNULL(AVG(score),0) as average from reviews LEFT OUTER JOIN movies ON movies.id = reviews.movie_id group by reviews.movie_id HAVING average < 2
I got a generic message saying that something is wrong with the statement even if the statement itself actually works.
Thanks for your help
1 Answer
Jason Anello
Courses Plus Student 94,610 PointsHi Luca,
You should be able to pass if you reverse the order of the movies and reviews tables around the LEFT OUTER JOIN
Should be:
movies LEFT OUTER JOIN reviews
Whatever table is on the left will have all of it's rows included. The table on the right will only have rows included that match the ON
criteria.
The movies table should be on the left to make sure that every movie is included in the results rather than only the movies that have reviews.