Your question is Window Functions for Analytics. 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.
Principal Financial Group needs a quarterly view of the strongest contributors across its retirement plans. Write a PostgreSQL query that ranks active participants by their total employee contributions during the first quarter of 2025.
ACTIVE status and contributions dated from January 1 through March 31, 2025.ROW_NUMBER() partitioned by plan_id, return the top two participants per plan, and apply deterministic tie-breaking by participant_id.| Column | Type | Description |
|---|---|---|
| participant_idPK | INTEGER | Unique participant identifier |
| plan_id | VARCHAR(30) | Retirement plan identifier |
| participant_name | VARCHAR(100) | Participant full name |
| status | VARCHAR(20) | Participant status, such as ACTIVE or INACTIVE |
| Column | Type | Description |
|---|---|---|
| contribution_idPK | INTEGER | Unique contribution identifier |
| participant_id | INTEGER | Participant associated with the contribution |
| contribution_date | DATE | Date the contribution was recorded |
| employee_contribution | NUMERIC(12,2) | Employee contribution amount |