66. Rapid Patient Re-admission Tracking

Hard Stripe Advanced & Tricky Problems
Query Rules
  • The query columns and order must match the expected result schema.
  • NULL values should be handled appropriately where applicable.
  • The grader compares output values and sorting order to evaluate.

Schema Browser

Click a table's header to toggle expand/collapse.
patients
10 cols
doctors
4 cols
admissions
7 cols
province_names
2 cols

Reference Solution

Expected SQL
SELECT a1.patient_id, CAST(JULIANDAY(a2.admission_date) - JULIANDAY(a1.discharge_date) AS INT) as days_diff FROM admissions a1 JOIN admissions a2 ON a1.patient_id = a2.patient_id AND a2.admission_date > a1.discharge_date WHERE (JULIANDAY(a2.admission_date) - JULIANDAY(a1.discharge_date)) <= 30;
SQL Editor
Ctrl+Enter to run
Console Output

Console Terminal

Write your query and click "Run Query" (Ctrl + Enter) to see results and testcase validation.