How would you write an SQL query using window functions to solve a risk or analytics problem?
Use the provided risk_events and desks tables. Calculate positive account exposure for January 2025 and rank accounts within each region, excluding non-positive totals and unmatched desk records.
region, desk_name, account_id, total_exposure, and exposure_rank.| Column | Type | Description |
|---|---|---|
| desk_idPK | INT | Unique desk identifier |
| desk_name | VARCHAR(100) | Desk name |
| region | VARCHAR(50) | Reporting region |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique risk event identifier |
| desk_id | INT | Referenced desk identifier |
| account_id | VARCHAR(30) | Risk account identifier |
| event_date | DATE | Date of the risk event |
| exposure | DECIMAL(12,2) | Exposure amount for the event |