SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

Amazon: Monthly Category Revenue Pivot

Unsolved

Retail executives track seasonal category performance across marketplace orders. Write a query to pivot order revenue by calendar month into separate category columns for 'Electronics', 'Apparel', and 'Home'. Output four columns: `order_month` (formatted as 'YYYY-MM'), `electronics_rev`, `apparel_rev`, and `home_rev`. Revenue is calculated as the sum of `quantity * unit_price` for products in that category. If a category generated zero sales in a given month, report 0 (not NULL). Order the result chronologically by `order_month` ascending.

SQL Query Editor (Ctrl+Enter to run)
0 characters · Valid
Canonical Solution Official

Official Solution is Hidden

Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.

Community Q&A & Discussion

Ask questions, share alternate queries, and explore solutions

0 comments
Asked By:
🏢 Amazon

Submission History

Your recent query executions and answer checks

Execution Pipeline:
FROM orders
Full source dataset
9 rows total
Ready. Type a query to see live execution.
Clause: Auto-Sync · AlaSQL Engine