Multi-key GROUP BY (month + channel), date_trunc, multi-column ORDER BY. The shape behind every channel-mix-shift exec briefing.
I need to see the channel mix shift Oct 2025 → Mar 2026 (last 6 months). Bucket by month and channel. Three columns: month (first of each month), channel, order_count. ORDER BY month ASC then channel ASC. We're trying to see whether store_ship_from_store is taking share from web_ship — eyeball the trend.
| Column | Type | Key |
|---|---|---|
| order_id | INT | PK |
| sku_id | INT | FK → dim_skus |
| store_id | INT | FK → dim_stores |
| channel | TEXT | |
| customer_zip | TEXT | |
| order_ts | TEXT | |
| units | INT | |
| gross_amount | REAL | |
| discount_amount | REAL | |
| fulfillment_cost | REAL |
Each hint you reveal reduces the XP you can earn. Try the query first.
Filter order_ts >= '2025-10-01' AND order_ts < '2026-04-01'.
DATE_TRUNC('month', order_ts::timestamp)::date for the month bucket.
GROUP BY both month and channel so each (month, channel) pair gets its own row.
ORDER BY month ASC, channel ASC.