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

When I type in the following code, it's saying that my code didn't yield the proper results. I can't understand why.

Here's my code. I'm pulling the Min and Max for only the movie called "Starman".

SELECT MIN(rating) AS star_min, MAX(rating) AS star_max, movie_id FROM reviews WHERE movie_id = 6;

https://teamtreehouse.com/library/reporting-with-sql/aggregate-and-numeric-functions/calculating-the-minimum-and-maximum-values

3 Answers

Steven Parker
Steven Parker
231,261 Points

You were really close.

You just did a little too much. The challenge didn't ask for the movie_id to be shown.

Just remove that term from the SELECT list.

donald kaiser
donald kaiser
9,736 Points

Ok thanks Steven. I just tried this and it's saying that my calculation is wrong.

SELECT MIN(rating) AS star_min, MAX(rating) AS star_max FROM reviews

Absolutely nothing that I'm trying is working. I even tried this: SELECT AVG(rating) AS average, MIN(rating) AS star_min, MAX(rating) AS star_max FROM reviews GROUP BY id;

Steven Parker
Steven Parker
231,261 Points

But now you're forgetting the WHERE clause to filter on the movie_id. Your original code was good except that you did not need to SELECT the movie_id.

donald kaiser
donald kaiser
9,736 Points

Oh, ok. I tried that but also deleted the WHERE clause too. So that's why it didn't work. But it worked now. aaaaaahhhh thank God! Thanks steven.