~/ 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/dafc1f24-fb73-42c2-8061-83b84b77a661/flashcard utf-8 LF