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

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
229,670 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.