About this problem
This problem practises the simplest kind of pivot: turning rows into named columns with conditional aggregation. cat_monthly stores revenue in long form, one row per category and month, and the business wants a single summary line with lifetime revenue for electronics, books and clothing side by side. Each output column is a SUM over only the rows for its category. The key decision is the grain of the result: one row for the whole table, so there is nothing to group by at all.
The mistake that catches people is adding a GROUP BY out of habit. Grouping by month gives one row per month, which is a different, perfectly sensible-looking table; grouping by category gives three rows with two empty columns on each. Both run without errors and show correct numbers in some cells, so they are easy to accept at a glance, but the requirement says a single row. Watch also for a bare CASE expression with no aggregate around it: each source row keeps its own output row and you are back to one row per category and month, mostly blanks. Finally, the sample uses lowercase category names, so a CASE test written with different capitalisation simply never matches and that column comes out empty.
Read the lesson: Pivoting & Reshaping (P20) →