Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Handle Missing Values in SQL

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

Your question is Handle Missing Values in SQL. 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 analytics teams need consistent encounter fields before using clinical records in reporting and downstream analysis. Write a PostgreSQL query against the clinical_encounters table that handles missing pain scores and discharge dispositions using CASE WHEN logic.

Requirements

  1. Return every encounter, ordered by encounter_id.
  2. Replace a missing pain_score with 0 in a column named standardized_pain_score.
  3. Replace a missing discharge_disposition with Unknown in a column named standardized_disposition, while preserving existing values.

Schema

clinical_encounters
ColumnTypeDescription
encounter_idPKINTUnique clinical encounter identifier
patient_idINTIdentifier for the patient
encounter_dateDATEDate of the encounter
care_settingVARCHAR(30)Setting where care was delivered
pain_scoreINTPatient-reported pain score from 0 to 10
discharge_dispositionVARCHAR(30)Patient destination or outcome at discharge
Tablesclinical_encounters
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results