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 Reporting with SQL Aggregate and Numeric Functions Counting Results

Don't understand why I get an error

Not sure what is wrong with my code. SELECT COUNT(*) FROM books WHERE genre = "Science Fiction" AS scifi_book_count;

1 Answer

Emmanuel C
Emmanuel C
10,636 Points

This one was a bit tricky, but its not asking to count all the rows, its only asking for the genre. Also the alias should be declared right after the column names. I queried this and it worked.

SELECT COUNT(genre) as scifi_book_count FROM books WHERE genre = 'Science Fiction' ;

Itll be the same with the second task. Just a different column.

Thank you!! I figured it out after I had submitted the question. I appreciate the help. :)