Your question is Top Merchants Per City SQL. 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.
DoorDash wants to identify the highest-volume merchants in each city using completed orders. Write a PostgreSQL query that returns the top three merchants by total sales amount within every city.
orders to merchants to display merchant names.order_status = 'completed' and a non-null city.| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| merchant_id | INT | Merchant associated with the order |
| city | VARCHAR(100) | Delivery city |
| order_status | VARCHAR(20) | Order state, such as completed or cancelled |
| order_total | DECIMAL(10,2) | Customer order amount |
| Column | Type | Description |
|---|---|---|
| merchant_idPK | INT | Unique merchant identifier |
| merchant_name | VARCHAR(150) | Merchant display name |