Your question is SQL Top 3 Revenue Per Region. 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.
Write a SQL query to rank customers by revenue within each region and return the top 3 per region.
Calculate revenue from all matching sales orders. Null revenue values should contribute zero. Customers tied at the same revenue must share a rank, and include every customer whose rank is 3 or better.
region, customer_id, customer_name, total_revenue, and revenue_rank.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(150) | Customer name |
| region | VARCHAR(50) | Sales region assigned to the customer |
| Column | Type | Description |
|---|---|---|
| sales_order_idPK | INT | Unique sales order identifier |
| customer_id | INT | Customer associated with the sales order |
| order_date | DATE | Date the order was recorded |
| revenue | DECIMAL(12,2) | Revenue attributed to the order |