Your question is Window Function Ranking Claims. 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.
The Hanover Insurance Group wants to review open claims by active customer, with the highest-value claims shown first. Write a PostgreSQL query using a window function to rank each qualifying claim within its customer.
customers to claims using customer_id.claim_status = 'OPEN' and a non-null claim amount.RANK() to rank claims by claim_amount in descending order within each customer. Tied amounts must receive the same rank.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique policyholder identifier |
| customer_name | VARCHAR(100) | Policyholder name |
| is_active | BOOLEAN | Whether the customer is currently active |
| Column | Type | Description |
|---|---|---|
| claim_idPK | INT | Unique claim identifier |
| customer_id | INT | Customer associated with the claim |
| claim_amount | DECIMAL(12,2) | Reported claim amount |
| claim_status | VARCHAR(20) | Current claim status |