
Delivery time by cuisine
mediumDelivery time by cuisine
DoorDash SQL Interview Question
DoorDash's logistics team wants to see whether some kinds of food take longer to reach customers. Every delivery comes from a restaurant, and every restaurant serves one cuisine.
For each cuisine, find the average number of minutes from order to delivery, as avg_delivery_minutes, rounded to 1 decimal place. Only include orders that were delivered.
Asked of
- Data Analyst
- Product Analyst
- BI Analyst
- Analytics Engineer
- Data Scientist
deliveriesTable12 rows
| Column Name | Type |
|---|---|
| delivery_id | BIGINT |
| restaurant_id | BIGINT |
| dasher_id | BIGINT |
| ordered_at | TIMESTAMP |
| delivered_at | TIMESTAMP |
| order_value | DOUBLE |
| status | VARCHAR |
restaurantsTable6 rows
| Column Name | Type |
|---|---|
| restaurant_id | BIGINT |
| restaurant_name | VARCHAR |
| cuisine | VARCHAR |
| city | VARCHAR |
deliveriesExample Input
| delivery_id | restaurant_id | dasher_id | ordered_at | delivered_at | order_value | status |
|---|---|---|---|---|---|---|
| 7001 | 1 | 51 | 2024-04-12 11:58:00 | 2024-04-12 12:26:00 | 32.4 | delivered |
| 7002 | 2 | 52 | 2024-04-12 12:05:00 | 2024-04-12 12:41:00 | 27.8 | delivered |
| 7003 | 3 | 53 | 2024-04-12 12:20:00 | NULL | 18.5 | canceled |
| 7004 | 4 | 54 | 2024-04-12 18:02:00 | 2024-04-12 18:48:00 | 45.6 | delivered |
| 7005 | 5 | 55 | 2024-04-12 18:15:00 | 2024-04-12 18:37:00 | 22.1 | delivered |
| 7006 | 1 | 52 | 2024-04-12 18:30:00 | 2024-04-12 19:04:00 | 41.25 | delivered |
| 7007 | 6 | 56 | 2024-04-12 19:10:00 | 2024-04-12 19:52:00 | 36.9 | delivered |
restaurantsExample Input
| restaurant_id | restaurant_name | cuisine | city |
|---|---|---|---|
| 1 | Taco Loco | Mexican | San Francisco |
| 2 | Pho Real | Vietnamese | San Francisco |
| 3 | Burger Barn | American | San Francisco |
| 4 | Curry House | Indian | Denver |
| 5 | Nacho Mama | Mexican | Denver |
| 6 | Big Bite Burgers | American | Denver |
Example Output
| cuisine | avg_delivery_minutes |
|---|---|
| American | 42 |
| Indian | 46 |
| Mexican | 28 |
| Vietnamese | 36 |
Explanation
Taco Loco's two deliveries took 28 and 34 minutes, and Nacho Mama's delivery took 22 minutes. Both are Mexican restaurants, so Mexican averages 28.0 minutes. The Burger Barn order was canceled and never delivered, so American is based only on the 42-minute Big Bite Burgers delivery.
The example above is a small slice of the data. Your query runs against the full tables.
Company
DoorDash
Difficulty
medium
Topic
dates
Your query
Starting the SQL engine...