COUNT with WHERE on a status column
How many POs are still OPEN in `fact_purchase_orders`? Single number, alias `open_po_count`.
| 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 |
Each hint you reveal reduces the XP you can earn. Try the query first.
Filter the row set to one specific status value before counting.
Use COUNT(*).
Alias the column.