Clinical Operations Analytics Path · Mission 7 of 25Medium

Top 10 most-documented codes

JOIN + GROUP BY + COUNT + ORDER BY DESC + LIMIT — the canonical 'top N by frequency' pattern. All-rank version of the M21 Master mission, which restricts to Principal only.

The Brief

Dr. Marcus ChenChief Medical Officerslack-dm

Different cut from last week. The board narrative talks about *principal* diagnoses (M21 — top conditions that drove an admission), but for the coding department's continuing-ed planning I want the *most-documented* diagnoses, any rank — what codes is our coding team writing the most, period? Top 10 by raw frequency across all dx_types. Code, description, count. Order by count descending. This includes secondary comorbidities, so I expect HTN and hyperlipidemia to lead — they ride along on almost every chart.

You'll practice

JOINGROUP BYORDER BY DESCLIMIT

Tables & columns available

fact_diagnosesfact6 columns
ColumnTypeKey
diagnosis_idINTPK
encounter_idINTFK → fact_encounters
icd_codeTEXTFK → dim_icd
dx_typeTEXT
poa_indicatorTEXT
dx_rankINT
dim_icddim7 columns
ColumnTypeKey
icd_codeTEXTPK
icd_descriptionTEXT
ccsr_categoryTEXT
ccsr_descriptionTEXT
body_systemTEXT
is_chronicINT
hcc_flagINT

Hints (3)

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

Hint 1

Same JOIN as M6 — fact_diagnoses to dim_icd on icd_code. No dx_type filter; we want all rank levels.

Hint 2

GROUP BY icd_code, icd_description with COUNT(*) AS dx_count. Output three columns: icd_code, icd_description, dx_count.

Hint 3

ORDER BY dx_count DESC, LIMIT 10 — Dr. Chen wants the top 10 only. Compare your top 10 to the Master M21 list — the differences (chronic comorbidity codes that don't drive admissions) are the lesson.