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

Development Tools

Database 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.

You're returning more information than they're asking for. Review what columns you're selecting.

Well 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

Well 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?

Their 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.

Short 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.