Your question is Top Customers Per Region. Start with the requirements and the three 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.
Abzooba needs a regional revenue leaderboard for its customer analytics platform. Assume the reporting date is 2025-03-31, and the last 30 days means 2025-03-02 through 2025-03-31, inclusive. Write a PostgreSQL query to identify the top three customers by completed-order revenue in each region.
quantity * unit_price per customer, treating missing revenue as zero.| Column | Type | Description |
|---|---|---|
| region_idPK | INT | Unique region identifier |
| region_name | VARCHAR(50) | Display name of the region |
| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer full name |
| region_id | INT | Region assigned to the customer |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| customer_id | INT | Customer associated with the order |
| order_date | DATE | Date on which the order was placed |
| status | VARCHAR(20) | Order processing status |
| quantity | INT | Number of units ordered |
| unit_price | NUMERIC(10,2) | Price per ordered unit |