A newspaper reached out to Bindle asking how many categories they have in the library?
In the previous lesson, our SQL toolbox grew by one more item – DISTINCT
. It allows us to select unique column values or unique combinations in the case of several columns.
This lesson asks a more complex question – we need to count unique values. As we already know we can use the aggregate function COUNT
to count records:
SELECT COUNT(genre) FROM books
This query still returns the total number of books, since we just counted genres for each book.
To count...