Patients who were discharged from a hospital and readmitted within 30 days could suggest the quality of the hospital. A hospital with high admission rate may get less reimbursement from an insurance company.
Write an query to find all 30-day readmissions. Include patient id (pid), the readmission visit, and the last admission (index admission) before the admission.