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 trialdonald kaiser
9,736 PointsIt says I'm missing a WHERE clause but I didn't think WHERE clauses were necessary in this type of task. Please help.
https://teamtreehouse.com/library/reporting-with-sql/aggregate-and-numeric-functions/summing-values
I'm not understanding what the task wants me to do here.
4 Answers
Steven Parker
231,271 PointsYou 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
9,736 PointsHi 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
9,736 PointsIt 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
9,736 PointsOh ok. This was so confusing but I did it and it worked. Thank you.
Krishna Pratap Chouhan
15,203 PointsKrishna Pratap Chouhan
15,203 PointsHow 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.