Your question is Average Hospital Stay Duration. Start with the requirements and the one table on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
MediCore Hospital wants to measure the typical length of stay for completed patient visits. Write a SQL query to calculate the average time between admission and discharge using a single table.
discharge_time is not NULL| Column | Type | Description |
|---|---|---|
| admission_idPK | INT | Unique admission record ID |
| patient_name | VARCHAR(100) | Patient full name |
| department | VARCHAR(50) | Hospital department handling the admission |
| admission_time | TIMESTAMP | Timestamp when the patient was admitted |
| discharge_time | TIMESTAMP | Timestamp when the patient was discharged; NULL for active stays |