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.

Databases

donald kaiser
donald kaiser
9,736 Points

It says I'm missing a WHERE clause but I didn't think WHERE clauses were necessary in this type of task. Please help.

How are you planning to write the query, could you please share it Donald. I can't figure out how come we dont need WHERE clause.

4 Answers

Steven Parker
Steven Parker
216,083 Points

You need a WHERE clause to identify the movie.

The instructions ask you to total the ratings for the movie Starman. You would use a WHERE clause to make sure your total only includes the ratings for that particular movie.

And you won't need grouping for this challenge.

donald kaiser
donald kaiser
9,736 Points

Hi Krishna. Here is the code I'm attempting.

SELECT SUM(rating) AS starman_total_ratings, movie_id FROM reviews GROUP BY movie_id HAVING starman_total_ratings > 0;

donald kaiser
donald kaiser
9,736 Points

It doesn't make sense because in the video, he said that you shouldn't use a WHERE clause when grouping since SQL doesn't know what to do with it. So it's better to use the HAVING type of where clause. But it's still saying that I need a WHERE clause. This is very confusing.

donald kaiser
donald kaiser
9,736 Points

Oh ok. This was so confusing but I did it and it worked. Thank you.