Provider Analytics Path · Mission 9 of 25Easy

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

An INNER JOIN silently drops rows with no match. You need the join variant that keeps every department regardless

Hint 2

After the outer join, filter for rows where no encounter was matched — the right-side key will be missing

Hint 3

`SELECT d.department_name, d.department_type FROM dim_departments d ___ JOIN fact_encounters e ON d.department_id = e.department_id WHERE e.encounter_id IS ___`