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.
Output
- One row per qualifying merchant or customer segment.
- Columns:
entity_type, entity_name, order_count, total_order_value, and performance_rank.
- Include ties only when they fall within the top three ranks. Sort by entity type, rank, and entity name.