GROUP BY with COUNT
How many POs has each supplier received? Show supplier_name and po_count, sorted descending.
| Column | Type | Key |
|---|---|---|
| po_id | INT | PK |
| supplier_id | INT | FK → dim_suppliers |
| category_id | INT | FK → dim_categories |
| contract_id | INT | FK → dim_contracts |
| req_date | TEXT | |
| po_date | TEXT | |
| ack_date | TEXT | |
| asn_date | TEXT | |
| gr_date | TEXT | |
| invoice_date | TEXT | |
| qty_ordered | INT | |
| qty_received | INT | |
| unit_price | REAL | |
| contracted_price | REAL | |
| status | 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 POs to suppliers.
GROUP BY supplier_name, COUNT(*).
ORDER BY po_count DESC.