Your question is Rolling Member Claim Totals SQL. Start with the requirements and the two 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.
Aetna's member analytics team needs monthly claim trend metrics for members. Write a PostgreSQL query that aggregates claim amounts by member and calendar month, then calculates both cumulative claim totals and a rolling three-month average.
| Column | Type | Description |
|---|---|---|
| member_idPK | INT | Unique member identifier |
| member_name | VARCHAR(100) | Member's full name |
| plan_type | VARCHAR(30) | Aetna health plan type |
| Column | Type | Description |
|---|---|---|
| claim_idPK | INT | Unique claim identifier |
| member_id | INT | Member associated with the claim |
| claim_date | DATE | Date the claim was submitted |
| claim_amount | NUMERIC(12,2) | Allowed claim amount |