Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top Readmission Rates Query

HardSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Top Readmission Rates Query. Start with the requirements and the three tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Dana-Farber Cancer Institute needs to identify departments with the highest patient readmission rates. A readmission is a subsequent admission for the same patient within 30 days after discharge from an eligible index admission.

Write a PostgreSQL query that analyzes index admissions from the six months ending on the query execution date. For sample-data verification, assume the query runs on 2026-08-29.

Requirements

  1. Consider only admissions whose admission date falls within the last six months and whose discharge date is not null.
  2. Identify the first subsequent admission for the same patient within 30 days after discharge.
  3. Calculate each department's eligible admission count, readmitted admission count, and readmission rate as a percentage.
  4. Return the top three departments, ranking ties deterministically by department name.

Schema

departments
ColumnTypeDescription
department_idPKINTUnique department identifier
department_nameVARCHAR(100)Dana-Farber department name
patients
ColumnTypeDescription
patient_idPKINTUnique patient identifier
patient_nameVARCHAR(100)Illustrative patient name
admissions
ColumnTypeDescription
admission_idPKINTUnique admission identifier
patient_idINTPatient associated with the admission
department_idINTDepartment responsible for the admission
admit_dateDATEDate the patient was admitted
discharge_dateDATEDate the patient was discharged
admission_typeVARCHAR(30)Admission classification
Tablesdepartmentspatientsadmissions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results