Write a SQL query to find the average length of stay for patients in a specific department.
Use the provided patient, department, and admission data. Calculate length of stay in days using completed admissions only, and filter the result to the Cardiology department.
department_name and average_length_of_stay_days.| Column | Type | Description |
|---|---|---|
| patient_idPK | INT | Unique patient identifier |
| first_name | VARCHAR(50) | Patient first name |
| last_name | VARCHAR(50) | Patient last name |
| Column | Type | Description |
|---|---|---|
| department_idPK | INT | Unique department identifier |
| department_name | VARCHAR(100) | Hospital department name |
| Column | Type | Description |
|---|---|---|
| admission_idPK | INT | Unique admission identifier |
| patient_id | INT | Admitted patient identifier |
| department_id | INT | Department responsible for the admission |
| admitted_at | TIMESTAMP | Admission date and time |
| discharge_at | TIMESTAMP | Discharge date and time, null for an ongoing admission |