Your question is Top Merchants and Segments. 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.
How would you use SQL to identify the top-performing merchants and customer segments at DoorDash USA?
Use completed orders only and exclude customers without a defined segment. Return the top three merchants and top three customer segments, ranked separately by total order value.
entity_type, entity_name, order_count, total_order_value, and performance_rank.| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| merchant_id | INT | Merchant associated with the order |
| customer_id | INT | Customer who placed the order |
| order_status | VARCHAR(20) | Current order status |
| order_value | NUMERIC(10,2) | Order value in US dollars |
| order_date | DATE | Date the order was placed |
| Column | Type | Description |
|---|---|---|
| merchant_idPK | INT | Unique merchant identifier |
| merchant_name | VARCHAR(100) | Merchant display name |
| market | VARCHAR(50) | Primary US market |
| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer display name |
| customer_segment | VARCHAR(30) | Customer lifecycle or engagement segment |