Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

No Recorded Discharge Date

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

Your question is No Recorded Discharge Date. Start with the requirements and the one table 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

Providence data analysts need to identify patients who remain open in an encounter extract because no discharge date has been recorded. Write a PostgreSQL query using the patient_encounters table.

Requirements

  1. Return each patient with a missing discharge_date, including the patient ID, name, admission date, and care unit.
  2. Sort the results by earliest admission date first, then by patient ID.

A missing discharge date is represented by SQL NULL. Do not treat an empty string or a future discharge date as missing.

Schema

patient_encounters
ColumnTypeDescription
encounter_idPKINTEGERUnique encounter identifier
patient_idINTEGERUnique patient identifier
patient_nameVARCHAR(100)Patient's display name
admission_dateDATEDate the encounter began
discharge_dateDATEDate of discharge, or NULL when not recorded
care_unitVARCHAR(80)Providence care unit for the encounter
Tablespatient_encounters
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results