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 trialKohane Kagami
12,390 PointsPlease help me with this problem.
In the library database, how many books are with the genre of "Science Fiction"? Alias the result as scifi_book_count.
My code is as follows:
SELECT count(*) from books where genre="Science Fiction" as "scifi_book_count";
5 Answers
Simon Coates
28,694 Pointsmy guess is
SELECT count(*) as "scifi_book_count" from books where genre="Science Fiction" ;
but if you include a URL, I can test.
Kohane Kagami
12,390 PointsIt worked. Thank you very much!
Lucy Li
781 PointsI typed in
SELECT COUNT(*) AS scific_book_count FROM books WHERE genre="Science Fiction" ;
scific_book_count 6
But it says my query didn't perform the correct count.
Simon Coates
28,694 Pointsif you specify which challenge this is related to (a url?), then i can test it. Looks okay at a glance, apart from the spelling mistake ("scific_book_count" instead of "scifi_book_count").
Lucy Li
781 PointsAw it looks like it was my misspelling from this page: https://teamtreehouse.com/library/reporting-with-sql/aggregate-and-numeric-functions/counting-results-2
Thanks!
Aananya Vyas
20,157 Pointsselect count(id) AS scifi_book_count from books where genre= "Science Fiction";
try this!