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 trialJami Schwarzwalder
17,961 PointsThere is something wrong with your query. Challenge Task 3 of 3
I'm on the third Task in the Grouping, Joining, and Cleaning Up Challenge.
I believe I've written everything accurately, but my JOIN may not be working correctly.
2 Answers
Jason Anello
Courses Plus Student 94,610 PointsYou're pretty close with that.
In this part:
ON reivews.movie_id = movies.reviews_id
You have a typo on reviews
and the id in the movies table is id
not reviews_id
The only other issue is the order that you have your tables around the LEFT OUTER JOIN
reviews LEFT OUTER JOIN movies
With a left join, the table you place on the left side will have all of its rows included but the table on the right will not necessarily have all of its rows included. With it set like this we will get all of the movies that have a review but we will be missing any movies from the movies table that never got a review.
In this case, we need to make sure we've included all the movies from the movies table whether they have a review or not.
Jami Schwarzwalder
17,961 PointsI'm sorry I thought it attached my code
SELECT movies.title, IFNULL(AVG(score),0) AS "average" FROM reviews LEFT OUTER JOIN movies ON reivews.movie_id = movies.reviews_id GROUP BY movie_id HAVING average<2;
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi Jami,
Can you post what you've tried if you're still stuck on this?