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 trialbarak ben ishay
1,951 PointsCOUNTING RESULATS
what is worng with this quairy ?
SELECT count(*) FROM books WHERE genre = Science Fiction
ORDER BY id LIMT= 1;
4 Answers
Grigorij Schleifer
10,365 PointsHi Barak, a couple of issues.
You are not expected to LIMIT and order the query for this challenge.
I would suggest this code:
SELECT count(*) AS scifi_book_count -- alias your result as scifi_book_count
FROM books
WHERE genre = "Science Fiction"; -- here we need quotation marks to reference the genre
You dont need quotation marks if you reference a column name, but sinse the different genres are stored as text you need them.
Does this answer your question? Happy quering ...
barak ben ishay
1,951 Pointsgreat thanks!
Grigorij Schleifer
10,365 PointsI am happy to help. Just shout out here in the forum :)
barak ben ishay
1,951 PointsWhy do I put the As next to the count ? How does it know that it belongs to the genare and not to other coulm?
barak ben ishay
1,951 Pointslike how does it replace the genre with the new alias , how does it know?
barak ben ishay
1,951 Pointsbarak ben ishay
1,951 Pointsok. but isnt the AS alias, need to be like " the orignal name then the AS and then come scifi_book_count"?