Chapter 9 · Interview Level
25. Prescription Duration in Days
Medium20 XPHealthcare
Pharmacy analytics wants to know prescription durations. Calculate the number of days between start_date and end_date for each prescription. Return medication, start_date, end_date, and duration_days. Order by duration_days descending.
Tables
- PKidINT
- FKvisit_id→ visits.idINT
- medicationTEXT
- dosageTEXT
- frequencyTEXT
- start_dateTEXT
- end_dateTEXT
- refillsINT
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.