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

Nelson Govea
PLUS
Nelson Govea
Courses Plus Student 1,951 Points

Reporting with SQL

Challenge Task 1 of 2

We're using the library database again. There's a books table. There's a title, author, genre and first_published column. Write a query to obtain the first 5 books in the Fantasy genre ordered by the year released. Oldest first. Select all columns. Type in your command below. Get Help Check Work

The bottom is my command but returning a error message.

SELECT * FROM books WHERE genre ASC ORDER BY first_published ASC LIMIT 5;

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Try removing the ASC next to the genre column. You only need to order the column by the year published :-)

Nelson Govea
Nelson Govea
Courses Plus Student 1,951 Points

Hi Jonathan, tried what you suggested but it didn't work.

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hmm, that's interesting... let me find the code challenge and have a look...

Right... try this one and it should work this time.

SELECT * FROM books WHERE genre = 'Fantasy' ORDER BY first_published ASC LIMIT 5;

I led you down the wrong path I'm afraid because in removing the first ASC keyword and not replacing it with a value I led you to write an invalid query. But if you look at the question again you'll see we're looking to return a query that gives us the first 5 books of the Fantasy Genre. So you can put that in quotation marks and you should be good to go.

Nelson Govea
PLUS
Nelson Govea
Courses Plus Student 1,951 Points

HI Jonathan, that definitely worked, it didn't come to me that I needed to add 'Fantasy' to the clause. Thank you.