Chapter 7 · CTEs
22. Monthly Visit Trends with CTEs
Hard40 XPHealthcare
Using CTEs, calculate the monthly visit count and the month-over-month change in visits. Return the month (as YYYY-MM), visit count, previous month count, and the change. Order by month.
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.