Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Order Pickup Time SQL

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Order Pickup Time SQL. 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.

You need to log in / sign up to run or submit.

Problem

DoorDash operations teams monitor how quickly confirmed orders are picked up by Dashers. Write a PostgreSQL query that calculates this interval by restaurant.

Requirements

  1. Join the restaurant, order, and order log tables.
  2. Include only completed orders with non-null timestamps where pickup occurred at or after restaurant confirmation.
  3. Return each restaurant's valid order count and average confirmation-to-pickup time in minutes.
  4. Include only restaurants with at least two valid orders, sorted by average time descending and restaurant name ascending as a tie-breaker.

Schema

restaurants
ColumnTypeDescription
restaurant_idPKINTUnique restaurant identifier
restaurant_nameVARCHAR(100)Restaurant display name
orders
ColumnTypeDescription
order_idPKINTUnique DoorDash order identifier
restaurant_idINTRestaurant associated with the order
order_statusVARCHAR(20)Current order lifecycle status
order_logs
ColumnTypeDescription
order_idPKINTOrder associated with this log record
restaurant_confirmed_atTIMESTAMPTimestamp when the restaurant confirmed the order
dasher_picked_up_atTIMESTAMPTimestamp when the Dasher picked up the order
Tablesrestaurantsordersorder_logs
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results