How would you use SQL window functions to calculate a rolling 30-day patient readmission rate?
Assume an admission is a readmission when the same patient was discharged previously and is admitted again within 30 days. Calculate the rate for each admission date using admissions during the preceding 30 calendar days, including the current date.
admission_date, readmissions_30d, admissions_30d, and readmission_rateadmission_date ascending| Column | Type | Description |
|---|---|---|
| patient_idPK | VARCHAR(10) | Unique patient identifier |
| patient_name | VARCHAR(100) | Patient display name |
| Column | Type | Description |
|---|---|---|
| admission_idPK | INT | Unique admission identifier |
| patient_id | VARCHAR(10) | Patient associated with the admission |
| admission_date | DATE | Date the patient was admitted |
| discharge_date | DATE | Date the patient was discharged |