Filter dim_patient on a payer attribute via the IN clause. Medicare patients are the highest-volume payer cohort for any group practice with cardiology and orthopedics; pulling them out cleanly is the first step before any payer-specific analytics.
Linda wants a clean Medicare patient roster before the AR aging review. Medicare lives on two payer rows in dim_payer (payer_id 5 = Medicare, payer_id 6 = Medicare Advantage HMO), so filter dim_patient on primary_payer_id IN (5, 6). Output four columns: patient_name, date_of_birth, gender, primary_payer_id. Sort by date_of_birth ascending so the oldest patients lead (they're the longest tenured on Medicare), then alphabetical on patient_name as a stable tiebreaker.
| Column | Type | Key |
|---|---|---|
| patient_id | INT | PK |
| patient_name | TEXT | |
| date_of_birth | TEXT | |
| gender | TEXT | |
| primary_payer_id | INT | FK → dim_payer |
| secondary_payer_id | INT | FK → dim_payer |
Each hint you reveal reduces the XP you can earn. Try the query first.
Single-table SELECT with a WHERE filter. dim_patient has the primary_payer_id column; the IN clause covers both Medicare payer_ids in one filter.
No aggregation — one row per Medicare patient. Project the four columns Maria named (patient_name, date_of_birth, gender, primary_payer_id).
Stable two-level sort: oldest patients lead so date_of_birth ascending, with an alphabetic tiebreaker on patient_name when patients share a DOB.