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

Development Tools

Ashley Wile
Ashley Wile
8,452 Points

Task 2 for SQL Group, Join and Clean shows the proper answer from my code but responds as incorrect. Help please :)

SELECT AVG(score) AS average FROM reviews GROUP BY movie_id HAVING average > 2;

I passed task 1 with this code minus the HAVING statement and this is what was to be added to task 2. Show only averages greater than 2. Please help!

1 Answer

Joseph Kato
Joseph Kato
35,340 Points

Is the question asking you to "filter out any averages over 2"? If so, I think you need to flip your operator, making it:

SELECT AVG(score) AS average FROM reviews GROUP BY movie_id HAVING average <= 2;
Ashley Wile
Ashley Wile
8,452 Points

SELECT title, IFNULL(AVG(score).0) AS average FROM reviews LEFT OUTER JOIN reviews ON movies.id = reviews.movie_id GROUP BY movie_id HAVING average <= 2;

Thank you for your help on Task 2. I think I have been on the computer too long :) Would you mind taking a look at the above statement for task 3? I have tried many ways but I cannot get anything to work.

Ashley Wile
Ashley Wile
8,452 Points

I fixed the issues. It was originally I was using a decimal for setting the IFNULL statement to 0 instead of a comma. I went back to original code and changed and worked!

Thank you so much for all of your help!