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.

Development Tools Database Foundations Reading Data from Databases with SQL Limiting the Result Set

Brian Schmitz
Brian Schmitz
11,167 Points

Where am I wrong here:

Order "movies" with the release "year" ascending with the "title" in alphabetical order.

SELECT * FROM movies ORDER BY year ASC, title;

6 Answers

kabir k
PLUS
kabir k
Courses Plus Student 18,036 Points

Even though writing the query as

SELECT * FROM movies ORDER BY year, title;

sorts the result set in ascending order by default (for MySQL), it's better to be explicit by adding an ordering keyword (e.g. ASC or DESC) for each column to guarantee the desired order as some SQL's may not sort the result set in ascending order by default.

So, in light of the question being asked, I wrote mine like so, and it passed.

SELECT * FROM movies ORDER BY year ASC, title ASC;
Sreng Hong
Sreng Hong
15,083 Points

I think you don't need to write 'ASC' at all since it's a default value.

SELECT * FROM movies ORDER BY year, title;

Database Foundations

Challenge Task 1 of 2

Order "actors" by "name" in reversed alphabetical order.

SELECT * FROM actors ORDER BY name DESC;

Challenge Task 2 of 2

Order "movies" with the release "year" ascending with the "title" in alphabetical order. Type in your command below, then press Enter.

SELECT * FROM movies ORDER BY year ASC, title ASC;

I had trouble with this too! Had to enter it about 4 times in order for it to work.

I had the same problem on Challenge Task 2 of 2, none of these combinations worked:

SELECT * FROM movies ORDER BY year, title; SELECT * FROM movies ORDER BY year ASC, title; SELECT * FROM movies ORDER BY year, title DESC; SELECT * FROM movies ORDER BY year ASC, title DESC;

These answers are wrong, but they also did not work, I tested them just to be thorough: SELECT * FROM movies ORDER BY title, year; SELECT * FROM movies ORDER BY title, year ASC; SELECT * FROM movies ORDER BY title DESC, year; SELECT * FROM movies ORDER BY title DESC, year ASC;

*** Update: I believe it has been fixed.

I have entered what I thought was correct in multiple times but it keeps returning bummer for the last couple of videos. The commands I am entering work just fine in the MySQL workbench.