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 trialTaylor Han
2,406 PointsCounting with SQL
SELECT COUNT(*) FROM books WHERE genre = "Science Fiction" AS scifi_book_count;
Trying to return the number of books in a database that are in the "Science Fiction" genre, and alias it. Tried a few different variations but not sure what I'm doing wrong.
Thanks!
1 Answer
Steven Parker
231,268 PointsIn SQL syntax an alias must immediately follow the item it applies to (in this case the "COUNT" function).
SELECT COUNT(*) AS scifi_book_count FROM books WHERE genre = "Science Fiction";
Taylor Han
2,406 PointsTaylor Han
2,406 PointsAh ok thank you! That has been a confusing thing with alias'.
Jack Chaffin
Courses Plus Student 4,462 PointsJack Chaffin
Courses Plus Student 4,462 PointsIs there anywhere we can find a good explanation of what order each operation needs to go in. I find that very confusing and frustrating. Is there maybe a rule of thumb or something?
Steven Parker
231,268 PointsSteven Parker
231,268 PointsI think what you want is often called a "cheat sheet". Here's a couple I found with a quick search:
However, despite the term "basics", these both include several things that probably have not been covered yet.