First exposure to NULL-as-a-value. POA (Present-On-Admission) is documented as Y/N/U or NULL when not recorded. GROUP BY surfaces the NULL bucket as its own row — this primes the M14 (POA documentation rate) and M24 (POA gaps audit) missions.
I'm prepping the HIM monthly report and need a quick distribution of POA indicators across all our diagnoses. POA is Y (present at admission), N (not present, hospital-acquired), U (clinically undetermined), or sometimes NULL when documentation didn't capture it. Give me a count of each value including the NULL bucket — that's the missing-documentation tally. Two columns: poa_indicator and dx_count, sorted by count descending.
| Column | Type | Key |
|---|---|---|
| diagnosis_id | INT | PK |
| encounter_id | INT | FK → fact_encounters |
| icd_code | TEXT | FK → dim_icd |
| dx_type | TEXT | |
| poa_indicator | TEXT | |
| dx_rank | INT |
Each hint you reveal reduces the XP you can earn. Try the query first.
Single table — fact_diagnoses. GROUP BY poa_indicator, COUNT(*).
GROUP BY treats NULL as a distinct group — it'll show up as its own row in the result. You don't need a special UNION or COALESCE; the engine handles it.
Four buckets to expect: Y (the bulk), N, U, and NULL. ORDER BY dx_count DESC so Y leads.