Create a materialized view genre_counts(genre, n) of books per genre, then count how many genres it has. Column: genres.
Create a materialized view genre_counts(genre, n) of books per genre, then count how many genres it has. Column: genres.
Answer
CREATE MATERIALIZED VIEW genre_counts AS SELECT genre, count(*) AS n FROM books GROUP BY genre; SELECT count(*) AS genres FROM genre_counts;