SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

Quarterly Revenue Pivot by Category

Unsolved

Shopify's merchant analytics dashboard needs a pivoted view of 2024 sales: one row per product category, with a separate column for each calendar quarter. Only sales dated in 2024 (`2024-01-01` to `2024-12-31`) count. Quarters are Q1 = Jan-Mar, Q2 = Apr-Jun, Q3 = Jul-Sep, Q4 = Oct-Dec. A quarter with no sales must show 0, not NULL. Return `category`, `q1_revenue`, `q2_revenue`, `q3_revenue`, `q4_revenue` and `total_revenue` (sum across all of 2024). Order the results by `category` 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🏢 Shopify🏢 Etsy

Submission History

Your recent query executions and answer checks

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