Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
SQL for Driver Completion Decline
00:00
5 left

SQL for Driver Completion Decline

MediumSQL · PostgreSQL

Problem

Uber Operations needs to identify drivers who completed at least 50 trips during the previous calendar month but had a lower completion rate during the most recent seven-day period. Assume the reporting snapshot date is 2025-03-31.

Write a PostgreSQL query that joins driver details with daily trip metrics.

Requirements

  1. Calculate each driver's monthly completion rate for February 2025.
  2. Calculate each driver's completion rate from March 25 through March 31, 2025.
  3. Return drivers with at least 50 completed trips last month and a strictly lower recent completion rate.
  4. Include driver ID, name, city, both rates, and completed trips for the prior month. Sort by monthly completed trips descending, then driver ID.

A completion rate is completed trips divided by requested trips. Treat a NULL completed-trip value as zero and avoid division by zero.

Schema

drivers
ColumnTypeDescription
driver_idPKINTUnique driver identifier
driver_nameVARCHAR(100)Driver's full name
cityVARCHAR(50)Uber operating city
statusVARCHAR(20)Current driver status
daily_driver_metrics
ColumnTypeDescription
metric_idPKINTUnique daily metric identifier
driver_idINTReferences drivers.driver_id
metric_dateDATEDate covered by the metric
requested_tripsINTTrips requested from the driver
completed_tripsINTTrips completed by the driver
Tablesdriversdaily_driver_metrics
Interviewer

Your question is SQL for Driver Completion Decline. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.