Use WHERE to filter by metric type and calculate aggregate statistics
Hi! I just got off a call with a patient family who waited 4 hours in the ED last Tuesday. Can you pull the average, minimum, and maximum ED wait times from our quality metrics? I want to bring data to the nursing leadership meeting tomorrow, not just anecdotes.
| Column | Type | Key |
|---|---|---|
| metric_id | INT | PK |
| encounter_id | INT | FK → fact_encounters |
| patient_id | INT | FK → dim_patients |
| metric_type | TEXT | |
| metric_value | REAL | |
| measurement_date | TEXT | |
| reported_by | TEXT |
Each hint you reveal reduces the XP you can earn. Try the query first.
ED wait times live in `fact_quality_metrics` under one specific metric_type. Everything else is the wrong metric
Three aggregates in a single SELECT, filtered to the right metric type. No GROUP BY — it's one summary row
`SELECT ___(metric_value) AS avg_wait, ___(metric_value) AS min_wait, ___(metric_value) AS max_wait FROM fact_quality_metrics WHERE metric_type = ___`