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.
Loading…
Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.
Ask questions, share alternate queries, and explore solutions
Your recent query executions and answer checks
This will insert the verified MySQL solution into your editor so you can study how each clause transforms the table.