Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL: Drivers Over Weekly Threshold
00:00
5 left

SQL: Drivers Over Weekly Threshold

MediumSQL · PostgreSQL

Problem

Given a table of customer deliveries, write a query to identify any delivery drivers who have completed more than a specific threshold of deliveries in a single week at Carvana.

Assume the threshold is supplied as PostgreSQL parameter \$1. Include only completed deliveries with a non-null delivery timestamp.

Output

  1. One row per driver and calendar week exceeding the threshold.
  2. Columns: driver_id, driver_name, week_start, and delivery_count.
  3. Order by week_start, then driver_id.

Schema

customer_deliveries
ColumnTypeDescription
delivery_idPKINTUnique delivery identifier
driver_idINTDriver assigned to the delivery
customer_idINTCustomer associated with the delivery
delivered_atTIMESTAMPTimestamp when the delivery was completed
delivery_statusVARCHAR(20)Delivery status
delivery_drivers
ColumnTypeDescription
driver_idPKINTUnique driver identifier
driver_nameVARCHAR(100)Driver's full name
Tablescustomer_deliveriesdelivery_drivers
Interviewer

Your question is SQL: Drivers Over Weekly Threshold. Start with the requirements and the two tables in the Question tab.

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.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.