~/ learn/ postgresql/ cards/ GROUP BY: per-category summaries
1 of 2

Count the number of books in each genre. Show genre and a count named books.

Count the number of books in each genre. Show genre and a count named books.

Answer

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

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/0a41c238-a7f1-4021-8ab7-9a9b927bcb5b/flashcard utf-8 LF