Chapter 9 · Interview Level
26. Visit Status Summary with CASE
Medium20 XPHealthcare
Create a summary of visits by classifying their status into broader categories. Use CASE to map: 'completed' -> 'Finished', 'cancelled' and 'no_show' -> 'Did Not Happen', 'scheduled' -> 'Upcoming'. Return status_category and visit_count. Order by visit_count descending.
Tables
- 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.