Filter on latest snapshot, JOIN to dim for readable output.
Stock-out risk alert: which SKUs have under 7 days of supply on the latest snapshot? Pull sku_name, warehouse_name, and days_of_supply. Use the latest snapshot date only. Same dedup trick as before — that table has duplicates.
| Column | Type | Key |
|---|---|---|
| snapshot_id | INT | PK |
| sku_id | INT | FK → dim_skus |
| warehouse_id | INT | FK → dim_warehouses |
| snapshot_date | TEXT | |
| on_hand_qty | INT | |
| days_of_supply | REAL |
| Column | Type | Key |
|---|---|---|
| sku_id | INT | PK |
| sku_code | TEXT | |
| sku_name | TEXT | |
| category | TEXT | |
| unit_cost | REAL | |
| reorder_point | INT |
| Column | Type | Key |
|---|---|---|
| warehouse_id | INT | PK |
| warehouse_name | TEXT | |
| region | TEXT |
Each hint you reveal reduces the XP you can earn. Try the query first.
Filter to the latest snapshot: `WHERE snapshot_date = (SELECT MAX(snapshot_date) FROM fact_inventory_snapshots)`.
Filter on `days_of_supply < 7`. JOIN to `dim_skus` for sku_name and `dim_warehouses` for warehouse_name.
Use DISTINCT to handle duplicate snapshot rows. ORDER BY days_of_supply ASC so the most-at-risk float to the top.