GROUP BY + ORDER BY + LIMIT
Top 10 suppliers ranked by total invoice spend. Show supplier_name, total_spend descending.
| 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.
Spend ranks roll up on the invoice side; bring supplier_name in from the dim, then group + sum + sort + cap.
GROUP BY, SUM(invoice_amount).
ORDER BY DESC, LIMIT 10.