Write a SQL query to join patient, admission, and discharge tables and calculate 30-day readmission rates by hospital. Count an admission as a readmission when the same patient is admitted again after discharge and within 30 calendar days. Use only admissions with a matching discharge record.
hospital_name, completed_admissions, readmissions_30_day, and readmission_rate_pcthospital_name ascending| Column | Type | Description |
|---|---|---|
| patient_idPK | INT | Unique patient identifier |
| patient_name | VARCHAR(100) | Patient's name |
| gender | VARCHAR(20) | Recorded gender |
| Column | Type | Description |
|---|---|---|
| admission_idPK | INT | Unique admission identifier |
| patient_id | INT | Patient associated with the admission |
| hospital_name | VARCHAR(100) | Hospital where the admission occurred |
| admit_date | DATE | Admission date |
| Column | Type | Description |
|---|---|---|
| discharge_idPK | INT | Unique discharge record identifier |
| admission_id | INT | Admission associated with the discharge |
| discharge_date | DATE | Date the patient was discharged |