Chapter 7 · CTEs
25. 30-Day Readmission Rate by Department
Hard40 XPHealthcare
Calculate the 30-day readmission rate per department. A readmission is when the same patient visits the same department within 30 days of a completed visit. Use CTEs to find readmissions, then compute the rate as readmissions / total completed visits * 100. Return department name, total_completed, readmission_count, and readmission_rate (rounded to 1 decimal). Order by readmission_rate descending.
Tables
- PKidINT
- first_nameTEXT
- last_nameTEXT
- specialtyTEXT
- FKdepartment_id→ departments.idINT
- emailTEXT
- phoneTEXT
- hire_dateTEXT
- salaryREAL
- PKidINT
- nameTEXT
- floorINT
- FKhead_doctor_id→ doctors.idINT
- budgetREAL
- PKidINT
- FKpatient_id→ patients.idINT
- FKdoctor_id→ doctors.idINT
- visit_dateTEXT
- diagnosisTEXT
- notesTEXT
- follow_up_dateTEXT
- statusTEXT
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.