Your question is Rank Users With SQL Window Functions. 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.
Basis Technologies wants to compare user revenue performance across countries in Basis DSP. Write a PostgreSQL query that aggregates credited revenue per user and ranks users against others in the same country.
| Column | Type | Description |
|---|---|---|
| user_idPK | INTEGER | Unique user identifier |
| user_name | VARCHAR(100) | User display name |
| country | VARCHAR(2) | Two-letter user country code |
| Column | Type | Description |
|---|---|---|
| event_idPK | INTEGER | Unique revenue event identifier |
| user_id | INTEGER | User associated with the revenue event |
| amount | NUMERIC(12,2) | Revenue amount |
| event_status | VARCHAR(20) | Revenue event processing status |