Use date arithmetic with NULL handling and GROUP BY
need avg length of stay in days by department for inpatient encounters only. exclude anyone still admitted (null discharge). round to 1 decimal. capacity planning meeting in 20 min.
Each hint you reveal reduces the XP you can earn. Try the query first.
Dates are stored as TEXT — you'll need to cast them to real dates before subtracting. LOS in days is one date minus the other
Filter rows first (inpatient only, discharged only), then aggregate with AVG grouped by department. Round the output
`SELECT d.department_name, ROUND(AVG(e.discharge_date::date - e.admit_date::date), ___) AS avg_los FROM fact_encounters e JOIN dim_departments d ON ___ WHERE e.encounter_type = ___ AND e.discharge_date IS NOT ___ GROUP BY ___`