Patient satisfaction is closely linked to wait times. UnitedHealth needs to monitor the operational efficiency of different clinics by analyzing how long a patient waits after checking in before a doctor is assigned to them.
Write a query to calculate the median wait time in minutes for each clinic.
| log_id(INTEGER) | clinic_id(INTEGER) | patient_id(INTEGER) | event_type(VARCHAR) | event_timestamp(TIMESTAMP) |
|---|---|---|---|---|
| 1 | 1 | 501 | Check-in | 2026-03-04 09:00:00 |
| 2 | 1 | 501 | Doctor Assigned | 2026-03-04 09:15:00 |
| 3 | 1 | 502 | Check-in | 2026-03-04 09:10:00 |
| 4 | 1 | 502 | Doctor Assigned | 2026-03-04 09:40:00 |
| 5 | 1 | 503 | Check-in | 2026-03-04 10:00:00 |
| 6 | 1 | 503 | Doctor Assigned | 2026-03-04 10:10:00 |
| 7 | 2 | 601 | Check-in | 2026-03-04 08:00:00 |
| 8 | 2 | 601 | Doctor Assigned | 2026-03-04 08:45:00 |
| 9 | 2 | 602 | Check-in | 2026-03-04 08:30:00 |
| 10 | 2 | 602 | Doctor Assigned | 2026-03-04 09:05:00 |
| clinic_id(INTEGER) | median_wait_minutes(DECIMAL) |
|---|---|
| 2 | 40 |
| 1 | 15 |