Healthcare Analytics Path · Mission 16 of 25Hard

Rank specialties by encounter volume

Use RANK() window function with data normalization

Back to Healthcare Analytics

The Brief

Dr. Linda NguyenChief Medical Officerclinical-analytics

Rank each medical specialty by total encounter volume. Normalize specialty names so 'Cardiology' and 'cardiology' aren't separate. Show specialty, encounter count, and rank. I need to know where to focus our recruiting — if Cardiology is our busiest specialty, we need another cardiologist.

You'll practice

RANK()LOWER()Window functions

Tables available

fact_encountersdim_providers

Hints (3)

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

Hint 1

Specialty lives in `dim_providers`, volume in `fact_encounters`. Casing inconsistency will split specialties if you don't normalize

Hint 2

Group by the normalized specialty, count encounters, then add a rank column via a window function that orders by that count

Hint 3

`SELECT LOWER(p.specialty) AS specialty, COUNT(*) AS encounter_count, ___() OVER (ORDER BY COUNT(*) ___) AS rank FROM fact_encounters e JOIN dim_providers p ON ___ GROUP BY ___`