Databases Reporting with SQL Aggregate and Numeric Functions Counting Groups

Tafari Carnegie
Tafari Carnegie
2,051 Points

select genre,count(distinct genre) as total_genres from books group by genre

Hi this is for challenge Task 2 of 2 and its to count all the distinct genres, I been on this for weeks and I can't figure it out

1 Answer

Steven Parker
Steven Parker
187,484 Points

The instructions ask you to "Write a query to count all the unique genres in the books table.", so you don't need a genre column or a GROUP BY:

select count(distinct genre) as total_genres from books;