Clinical Operations Analytics Path · Mission 8 of 25Medium

Body system distribution

Aggregate at the body_system grain with a computed % of total via a scalar subquery (or window function). First multi-aggregate query — count plus a percentage in the same SELECT. Float-promotion gotcha appears.

The Brief

Aisha PatelVP Clinical Operationsslack-dm

Strategic-planning week — I'm writing the service-line investment memo and need a quick high-level cut. Roll our diagnoses up to body system: how many diagnoses fall in each body system, and what percentage of all documented diagnoses does each system represent? Order by count descending so the dominant systems lead. I'd expect Circulatory and Respiratory in the top tier — that's the cardiopulmonary skew of an aging adult population.

You'll practice

JOINGROUP BY% calc + float promotionScalar subquery

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 two-table join as M6/M7 (fact_diagnoses to dim_icd), but group by the body system rollup instead of by individual code.

Hint 2

Percent of total = per-group count divided by the total count across all groups. The total can come from a scalar subquery on the same join. Float-promote the division so the percentage isn't truncated to 0.

Hint 3

Three output columns: the body system, the count, and the percentage. Round the percentage to one decimal; sort by count descending.