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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Zack Yovel](https://uploads.teamtreehouse.com/production/profile-photos/636402/micro_prof.jpg)
Zack Yovel
8,966 PointsNeed 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?
3 Answers
![Gareth Borcherds](https://secure.gravatar.com/avatar/ad3c077a4ad84608f68e5ffc90ab2636?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Gareth Borcherds
9,372 PointsI 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 <
![Zack Yovel](https://uploads.teamtreehouse.com/production/profile-photos/636402/micro_prof.jpg)
Zack Yovel
8,966 PointsProblem solved.
![Darren McDonald](https://secure.gravatar.com/avatar/48a72f9f13e85eebf6e502b95712f218?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Darren McDonald
1,481 PointsThank you both. This thread was great in helping me understand where I was going wrong in q3!
Darren.
Zack Yovel
8,966 PointsZack Yovel
8,966 PointsThank Gareth, your snippet helped me find what was wrong in mine and get through this task. Here's my final statement: