Brooksource wants a regional view of user spending across its analytics platform. Write a PostgreSQL query that calculates each user's completed purchase total for 2025 and ranks users within their region.
RANK() partitioned by region and ordered by total spend descending. Users tied on spend must share the same rank.completed and a purchase date in 2025.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| user_name | VARCHAR(100) | User's full name |
| region | VARCHAR(50) | User's assigned region |
| Column | Type | Description |
|---|---|---|
| purchase_idPK | INT | Unique purchase identifier |
| user_id | INT | User who made the purchase |
| purchase_date | DATE | Date the purchase was recorded |
| amount | NUMERIC(10,2) | Purchase amount |
| status | VARCHAR(20) | Purchase processing status |