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

Can someone please help on what's missing from this code?

Maybe I'm missing something really obvious...thanks!

SELECT genre, COUNT(genre) AS genre_count FROM books GROUP BY genre;

4 Answers

David Marec
David Marec
9,578 Points

Hi Leon,

perhaps i'm too late but the right code is

SELECT genre, count(*) AS genre_count FROM books GROUP BY genre;

You have to count with a star !

Raffael Dettling
Raffael Dettling
32,999 Points

You dont need the "," after genre

Thanks Raffael. Taking out the , results in the following error.

SQL Error: near "(": syntax error

Raffael Dettling
Raffael Dettling
32,999 Points

ok hm the thing is the "(" after count should be correct . Maybe you can find the syntax error on this side:

(https://www.w3schools.com/sql/sql_count_avg_sum.asp)

That worked perfectly. Thanks David!