EverC needs a regional leaderboard for users based on revenue recorded across its platform. Write a PostgreSQL query that calculates each user's total revenue and assigns a position within their region.
Include revenue adjustments in each user's total. Users whose total revenue is zero, negative, or not available should not appear in the leaderboard.
region, user_id, user_name, total_revenue, and revenue_rank.user_id so the output is deterministic.region, then revenue_rank, then user_id.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Primary key for the user |
| user_name | VARCHAR(100) | User display name |
| region | VARCHAR(50) | User's regional market |
| Column | Type | Description |
|---|---|---|
| revenue_idPK | INT | Primary key for the revenue event |
| user_id | INT | User associated with the revenue event |
| revenue_date | DATE | Date the revenue was recorded |
| amount | DECIMAL(10,2) | Revenue amount, including adjustments |
| source | VARCHAR(50) | Revenue source label |