Measure Late Deliveries and Identify Top Delayed Restaurants
Company: DoorDash
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Technical Screen
Overview: This question evaluates proficiency in time-based aggregations, timestamp arithmetic, percentage calculations, and ranking/grouping using SQL or equivalent Python data-manipulation libraries.
Daily late-delivery rate (last 7 days)
Tables
orders(order_id INT, user_id INT, restaurant_id INT, created_at TIMESTAMP, estimated_delivery_at TIMESTAMP, actual_delivery_at TIMESTAMP)
Hints
- Filter to the exact 7-day window using a half-open interval: >= 2025-05-26 and < 2025-06-02.
- Use a conditional count (e.g., FILTER or SUM(CASE...)) to compute late orders, then divide by total.
Top 5 restaurants by highest average delivery delay (last 7 days)
Tables
orders(order_id INT, user_id INT, restaurant_id INT, created_at TIMESTAMP, estimated_delivery_at TIMESTAMP, actual_delivery_at TIMESTAMP)
Hints
- Compute delay in minutes from the timestamp difference and clamp negative values to 0 with GREATEST().
- Aggregate by restaurant_id, then ORDER BY the average delay descending and LIMIT 5.
Community answers
Answer by SS