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!
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
Your Query Didn't Perform The Correct Count
"In the library database there's a books table. There are id, title, author, genre and first_published columns. Count all the books in each genre. Include the genre column first and the genre_count as the second column of information."
This is what I entered and I do not understand what is wrong.
SELECT genre, COUNT(genre) AS genre_count FROM books GROUP BY genre;
Steven Parker228,001 Points
Don't restrict your count.
You're already grouping by genre, so just count the rows ("
COUNT(*)" or "
Dustin Beaulieu1,279 Points
I am running into the same issue as above, and my code is identical. I believe the issue is that there is a genre that is null, with a count of 0. I then tried the statement below:
SELECT genre, COUNT(genre) AS "genre_count" FROM books WHERE genre IS NOT NULL GROUP BY genre;
This provided the results I wanted!!! .......but it still says it is not correct. UGH!