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

Benjamin Botwin
13,434 PointsThe last "Grouping, Joining, and Cleaning up" SQL Question.. I just can't get it.
I've been trying to get the last question in this for almost a month and nothing I try works.
I've tried this command on the mysql workbench and it seemed to work but on the website it doesn't.
select title, ifnull(avg(score), 0) as average from reviews left outer join movies on reviews.movie_id = movies.id group by movie_id having avg(score) <= 2;
Is it broken or am I doing something wrong?
Thanks, Ben

Benjamin Botwin
13,434 PointsThe last question on this page (https://teamtreehouse.com/library/grouping-joining-and-cleaning-up)
Sorry about that.
2 Answers

Sreng Hong
15,083 PointsHey I finally found the answer. Here it is:
select title, ifnull(avg(score),0) as average from movies left outer join reviews on movies.id = reviews.movie_id group by reviews.movie_id having average < 2;

Benjamin Botwin
13,434 PointsSo I was working on the wrong table... alright.
Thanks a lot!

Sreng Hong
15,083 PointsYour welcome

Cameron Lichtenstein
3,912 PointsJust to add to this, I was also having a problem with this same question. My original code was:
SELECT title, IFNULL (AVG(score), 0) AS average
FROM reviews LEFT OUTER JOIN movies ON reviews.movie_id = movies.id
GROUP BY movie_id
HAVING AVG(score) < 2;
I had the movies JOIN reviews instead of reviews JOIN movies as well.
The main problem that I had (and here's where I think this quiz can be improved) is that the error it kept telling me was that I was forgetting the IFNULL() function. Well, obviously I wasn't. So it was frustrating to debug.
Glad I checked the forum here — thanks for your posts guys.
Sreng Hong
15,083 PointsSreng Hong
15,083 Pointsdo you have a link to that question?