Your question is Rank Clients by Premium. Start with the requirements and the three 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.
Arthur J. Gallagher & needs a regional view of client premium performance. Write a PostgreSQL query that ranks clients by their total active policy premium within each assigned region.
RANK() partitioned by region, with the highest total premium receiving rank 1. Preserve ties by assigning the same rank.| Column | Type | Description |
|---|---|---|
| region_idPK | INT | Unique region identifier |
| region_name | VARCHAR(80) | Operating region name |
| Column | Type | Description |
|---|---|---|
| client_idPK | INT | Unique client identifier |
| client_name | VARCHAR(120) | Client legal or trading name |
| region_id | INT | Assigned region identifier |
| Column | Type | Description |
|---|---|---|
| policy_idPK | INT | Unique policy identifier |
| client_id | INT | Client that owns the policy |
| policy_number | VARCHAR(30) | Policy reference number |
| policy_status | VARCHAR(20) | Policy lifecycle status |
| premium_amount | NUMERIC(12,2) | Policy premium amount |