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 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
218,812 Points

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

Steven Parker
Steven Parker
218,812 Points

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