Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Percent Missing Values by Column

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

Your question is Percent Missing Values by Column. Start with the requirements and the two 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

Providence's encounter data quality process needs a column-level completeness report before patient-level analytics are published. Write a PostgreSQL query that calculates the percentage of missing values for every tracked column in providence_encounters.

Requirements

  1. Use providence_column_catalog to identify the columns that must be reported.
  2. Return the column name, missing-value count, total row count, and missing percentage rounded to two decimal places.
  3. Treat SQL NULL values as missing, and include columns with no missing values.
  4. Order results by missing percentage descending, then column name ascending.

Schema

providence_encounters
ColumnTypeDescription
encounter_idPKINTUnique encounter identifier
patient_idINTProvidence patient identifier
facilityVARCHAR(80)Care facility name
acuityVARCHAR(20)Encounter acuity level
discharge_dispositionVARCHAR(40)Discharge outcome
follow_up_daysINTDays until recommended follow-up
providence_column_catalog
ColumnTypeDescription
column_namePKVARCHAR(80)Name of a tracked encounter column
is_trackedBOOLEANWhether the column belongs in the completeness report
Tablesprovidence_encountersprovidence_column_catalog
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results