Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!