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.

Databases

Ondřej Straňanek
Ondřej Straňanek
19,637 Points

Find the earliest Science Fiction book in our library..

SELECT * FROM books WHERE genre = "Fiction" ORDER BY genre DESC, first_published ASC LIMIT 1;

That's my code and I don't know - what's wrong there, I tried many options, but sad nothing works.

https://teamtreehouse.com/library/reporting-with-sql/ordering-limiting-and-paging-results/limiting-results

Challenge Task 2 of 2

Thanks for any help!

2 Answers

They wanted "Science Fiction", not Fiction, and to order by ascending.

SELECT * FROM books WHERE genre = "Science Fiction" ORDER BY genre ASC, first_published LIMIT 1;
Steven Parker
Steven Parker
220,414 Points

:point_right: The genre you are looking for is "Science Fiction" (not just "Fiction").

Also, you don't need to include genre in the ORDER BY clause, since you are limiting the output to a single genre (and a single book).