GROUP BY a flag, with SUM
Split spend between preferred and non-preferred suppliers. Show is_preferred (0/1) and total_spend.
| Column | Type | Key |
|---|---|---|
| invoice_id | INT | PK |
| po_id | INT | FK → fact_purchase_orders |
| supplier_id | INT | FK → dim_suppliers |
| invoice_date | TEXT | |
| invoice_amount | REAL | |
| po_amount | REAL | |
| payment_date | TEXT |
| Column | Type | Key |
|---|---|---|
| supplier_id | INT | PK |
| supplier_name | TEXT | |
| country | TEXT | |
| tier | INT | |
| category_focus | TEXT | |
| diversity_certified | INT | |
| payment_terms_days | INT | |
| is_preferred | INT |
Each hint you reveal reduces the XP you can earn. Try the query first.
JOIN invoices to suppliers.
GROUP BY is_preferred.
SUM(invoice_amount).