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 Reporting with SQL Aggregate and Numeric Functions Summing Values

Christopher Parke
Christopher Parke
21,978 Points

Movie Ratings Question Confusing

I'm really confused why this doesn't work.

SELECT 
        SUM(rating) AS starman_total_ratings
FROM reviews
WHERE id=6;

Or this

SELECT
             SUM(rating) AS starman_total_ratings
FROM reviews
GROUP BY movie_id
HAVING id = 6;

I feel like the wording is ambiguous.

2 Answers

Christopher Parke
Christopher Parke
21,978 Points

Oh, I got it.

The instructions say that the reviews columns include both an id, and movie_id column.

It then states: "starman has an 'id' of 6 Immediately after it states: "Movie ids are found in the movie_id column."

So instead of simply writing "starman has a movie_id of 6" he has actually misstated that starman has an id of 6, and we have no information on the movie_id of starman.

We are to assume with no knowledge that the instructor meant movie_id, when he actually said id -- and there are two distinct columns.

Steven Parker
Steven Parker
231,184 Points

You may want to report this as a bug directly to the Support staff.

Steven Parker
Steven Parker
231,184 Points

You almost had it the first time, but instead of comparing "id" with 6, you'd want to compare "movie_id" instead.