Business Intelligence Path · Mission 14 of 25Medium

Pivot revenue by category and year

Use CASE WHEN inside aggregates to pivot rows into columns

Back to Business Intelligence

The Brief

Priya NairHead of Productproduct-analytics

I need a pivot table: one row per product category (normalized), with separate columns for 2023 revenue, 2024 revenue, and 2025 revenue. This is going into a slide deck so make it clean — four rows, four columns.

You'll practice

CASE pivotCross-tab

Tables available

fact_salesdim_products

Hints (3)

Each hint you reveal reduces the XP you can earn. Try the query first.

Hint 1

Use SUM(CASE WHEN year = 2023 THEN revenue ELSE 0 END) to create year-specific columns

Hint 2

Extract year from sale_date and normalize category with LOWER()

Hint 3

GROUP BY the normalized category