Welcome to the Treehouse Community
Looking to learn something new?
Need help with sql statement.
I'm attempting the code challange at http://teamtreehouse.com/library/grouping-joining-and-cleaning-up and have a problem with the third task. Here's my sql statement so far:
select movies.title, ifnull(avg(reviews.score),0) as average from reviews left outer join movies on movies.id = reviews.movie_id group by reviews.movie_id having average <= 2;
could anyone point me in the right direction?
Gareth Borcherds9,372 Points
I had to play around with it a bit, but I finally got the following to work. (even though what I was putting in before was the exact same thing)
select movies.title, IFNULL(AVG(reviews.score), 0) as average from movies left outer join reviews on movies.id = reviews.movie_id group by movie_id having average < 2
It might have something to do with you <= instead of just <
Thank you both. This thread was great in helping me understand where I was going wrong in q3!