Your question is Rank Top Users by Spend. 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.
Hirebeat wants to identify its highest-spending users in each country. Write a PostgreSQL query that calculates each user's total purchase spend, ranks users within their country, and returns the top three users per country.
0.user_id.| Column | Type | Description |
|---|---|---|
| user_idPK | INTEGER | Unique Hirebeat user identifier |
| user_name | VARCHAR(100) | User display name |
| country | VARCHAR(50) | User country |
| Column | Type | Description |
|---|---|---|
| purchase_idPK | INTEGER | Unique purchase identifier |
| user_id | INTEGER | Identifier of the purchasing user |
| amount | NUMERIC(10,2) | Purchase amount |