Clinical Operations Analytics Path · Mission 4 of 25Easy

Encounter diagnosis volume by type

First aggregation on fact_diagnoses. Reveals the Principal / Admit / Secondary distribution that every downstream mission filters on. GROUP BY a categorical column with COUNT(*).

The Brief

Riley SinghJunior Quality Analystslack-dm

Heads up — first day on quality and I'm trying to get my bearings on the diagnosis table. I see fact_diagnoses has a dx_type column with values like 'Principal' and 'Secondary' but I don't actually know how many of each we have in the data. Can you pull a count by dx_type so I have a baseline before I start filtering on it for the readmission stuff? Just dx_type and count, sorted with the biggest bucket on top.

You'll practice

GROUP BYCOUNT(*)Single-table aggregation

Tables & columns available

fact_diagnosesfact6 columns
ColumnTypeKey
diagnosis_idINTPK
encounter_idINTFK → fact_encounters
icd_codeTEXTFK → dim_icd
dx_typeTEXT
poa_indicatorTEXT
dx_rankINT

Hints (3)

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

Hint 1

Single table — fact_diagnoses. GROUP BY dx_type, COUNT(*) AS dx_count.

Hint 2

Three values to expect: Principal (one per encounter that has any dx), Admit (admit-time documentation, on inpatient/observation only), Secondary (comorbidities, multiple per encounter possible).

Hint 3

ORDER BY dx_count DESC so the biggest bucket leads — Riley's asking for the baseline view, biggest first.