GROUP BY + date filter + SUM, with category-normalization trap.
For our Q1 procurement review I need total units ordered per category for last quarter (Jan-Mar 2026). Pull from `fact_purchase_orders` joined to `dim_skus`, group by `category`, sum `qty_ordered`. Use the order date, not the arrival date — I care about when we placed the orders. Heads up: the category column has some casing inconsistency (a few SKUs got loaded as `electronics` lowercase). Normalize them — I want one row per real category.
| Column | Type | Key |
|---|---|---|
| po_id | INT | PK |
| po_number | TEXT | |
| sku_id | INT | FK → dim_skus |
| supplier_id | INT | FK → dim_suppliers |
| warehouse_id | INT | FK → dim_warehouses |
| order_date | TEXT | |
| expected_arrival | TEXT | |
| actual_arrival | TEXT | |
| qty_ordered | INT | |
| qty_received | INT | |
| unit_cost | REAL | |
| status | TEXT |
| Column | Type | Key |
|---|---|---|
| sku_id | INT | PK |
| sku_code | TEXT | |
| sku_name | TEXT | |
| category | TEXT | |
| unit_cost | REAL | |
| reorder_point | INT |
Each hint you reveal reduces the XP you can earn. Try the query first.
JOIN `fact_purchase_orders` to `dim_skus` ON `sku_id`. Filter `order_date BETWEEN '2026-01-01' AND '2026-03-31'`.
Wrap `category` in `LOWER()` so 'Electronics' and 'electronics' collapse to one bucket.
GROUP BY the normalized category, SUM(qty_ordered), ORDER BY category. Five rows total.