Provider Analytics Path · Mission 9 of 30Easy

Departments with no encounters

Use LEFT JOIN with IS NULL to find orphaned dimension records

Back to Provider Analytics

The Brief

Rita VasquezDirector of Patient Experiencequality-analytics

Dr. Okafor asked me to help audit the master data. Are there any departments in our system that have zero encounters? If so, we should either start using them or remove them from the system. Can you check?

You'll practice

LEFT JOINIS NULL

Tables & columns available

dim_departmentsdim6 columns
ColumnTypeKey
department_idINTPK
department_nameTEXT
department_typeTEXT
floorINT
bed_countINT
manager_nameTEXT
fact_encountersfact10 columns
ColumnTypeKey
encounter_idINTPK
patient_idINTFK → dim_patients
provider_idINTFK → dim_providers
department_idINTFK → dim_departments
admit_dateTEXT
discharge_dateTEXT
diagnosis_codeTEXT
diagnosis_descriptionTEXT
encounter_typeTEXT
discharge_dispositionTEXT

Hints (3)

Each hint you reveal reduces the XP you can earn. Try the query first.

Hint 1

Anti-join pattern: keep every row in the department dimension, then surface the ones with no matching encounter.

Hint 2

LEFT JOIN from departments to encounters, then WHERE the encounter-side key IS NULL.

Hint 3

An INNER JOIN silently drops orphans. The LEFT direction must be from the dimension to the fact, not the other way around.