Your question is SQL With Complex Joins and Aggregations. Start with the requirements and the four tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
OptumRx needs a member-level view of paid prescription utilization for the first quarter of 2025. Write a PostgreSQL query that combines member, prescription, claim, and pharmacy data.
2025-01-01 through 2025-03-31.Unknown and missing monetary values as zero during aggregation.| Column | Type | Description |
|---|---|---|
| member_idPK | INT | OptumRx member identifier |
| member_name | VARCHAR(100) | Member display name |
| is_active | BOOLEAN | Whether the member is currently active |
| Column | Type | Description |
|---|---|---|
| prescription_idPK | INT | Prescription identifier |
| member_id | INT | References members.member_id |
| drug_name | VARCHAR(100) | Medication name |
| Column | Type | Description |
|---|---|---|
| claim_idPK | INT | Prescription claim identifier |
| prescription_id | INT | References prescriptions.prescription_id |
| pharmacy_id | INT | References pharmacies.pharmacy_id when available |
| claim_date | DATE | Date the claim was processed |
| claim_status | VARCHAR(20) | Claim adjudication status |
| paid_amount | NUMERIC(10,2) | Amount paid for the claim |
| Column | Type | Description |
|---|---|---|
| pharmacy_idPK | INT | Pharmacy identifier |
| pharmacy_name | VARCHAR(120) | Pharmacy or dispensing channel name |