Your question is SQL Window Function Ranking. 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.
Accenture España wants to identify the highest-value customers in each sales region. Write a SQL query to rank customers by their total revenue within each region.
region and customer_id.| Column | Type | Description |
|---|---|---|
| region_idPK | INT | Primary key for the region |
| region_name | VARCHAR(100) | Region name |
| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Primary key for the customer |
| customer_name | VARCHAR(100) | Customer name |
| region_id | INT | Region assigned to the customer |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Primary key for the order |
| customer_id | INT | Customer who placed the order |
| order_status | VARCHAR(20) | Order status, such as completed or cancelled |
| order_amount | DECIMAL(10,2) | Revenue from the order |
| order_date | DATE | Order date |