About this problem
This problem practises a full long-to-wide pivot where the output grain is one row per month. You rotate cat_monthly, which has one row per (category, month, revenue), so that each month becomes a single line with revenue split into the fixed columns electronics, books and clothing. It is the shape a monthly report or chart needs. Alongside the conditional aggregation, you have to handle missing combinations deliberately: when a category has no row for a month, the prompt says that cell must show 0, not NULL.
Two mistakes are common. The first is grouping by both month and category, which keeps the long grain: each month appears three times, each row with one filled column and two empty ones. The pivot logic is fine; the grain is wrong. The second is the missing-cell rule. A SUM of a CASE that has no ELSE branch returns NULL when no row matches, so in the sample clothing has no row for December 2025 and comes out blank instead of 0. The prompt specifies zero, but a blank cell reads as “nothing sold” and is easy to accept. The sample also has home rows, a category outside the three fixed columns, and they must not leak into any of them. Sorting by a formatted month label is the last slip: text order is not time order, so December of one year can land after January of the next.
Read the lesson: Pivoting & Reshaping (P20) →