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 trialChris Grazioli
31,225 PointsDatabase Foundations Numeric and Aggregate Functions Code Challenge Task 2 of 3
I'm having trouble with the Numeric and Aggregate Functions code challenge, particularly task 2 of 3 where it ask you to:
In the "reviews" table, with columns "score" and "movie_id", return the minimum score for the movie with the id of 2. Alias the minimum score as "min_score".
SELECT MIN(score) AS min_score, movie_id FROM reviews WHERE movie_id = 2;
This sql statement keeps yielding an error and I could use a fresh pair of eyes.
This is what it return: Bummer! There's something wrong with your query, alias the MIN(score) AS min_score and SELECT from the 'reviews' table for 'movie_id' 2.
Chris Grazioli
31,225 PointsWell I only have two columns (the columns they specifically asked for) in the SELECT statement. One of which is being aliased. Are they not asking for movie_id? what am I missing?
3 Answers
Chris Grazioli
31,225 PointsWell I only have two columns (the columns they specifically asked for) in the SELECT statement. One of which is being aliased. Are they not asking for movie_id? what am I missing?
Sam Donald
36,305 PointsTheir asking you to use the movie_id
column as a reference point for selecting which results to include from the score
column. So the only time you should be using movie_id
is with the WHERE
clause.
Eric Levy
14,652 PointsShort of giving you the answer, you're selecting more columns than they're asking for. They don't want a result set with two columns. They only ask for you to "return the minimum score". That's it.
Eric Levy
14,652 PointsEric Levy
14,652 PointsYou're returning more information than they're asking for. Review what columns you're selecting.