Provider Analytics Path · Mission 4 of 30Starter

Encounters by department

Use GROUP BY with COUNT and ORDER BY to find top values

Back to Provider Analytics

The Brief

Dr. Amara OkaforChief Quality Officerquality-analytics

Break down our encounter volume by department. I need department name and encounter count, sorted by volume descending. This tells me where our patients are going and where to focus the quality review.

You'll practice

GROUP BYJOINORDER BY

Tables & columns available

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
dim_departmentsdim6 columns
ColumnTypeKey
department_idINTPK
department_nameTEXT
department_typeTEXT
floorINT
bed_countINT
manager_nameTEXT

Hints (3)

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

Hint 1

Two-table join from the encounter fact to the department dimension, then aggregate per department.

Hint 2

GROUP BY the department name, COUNT the encounter rows per group, ORDER BY the count descending.

Hint 3

Every department that has at least one encounter should land in the result; the busiest goes on top.