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 City-Week Completion and Delay
00:00
5 left

SQL for City-Week Completion and Delay

HardSQL · PostgreSQL

Problem

Write a SQL query to analyze operational performance by city and week, joining trip data with service status data to calculate completion rate, average delay, and week-over-week change. Use all trips as the operational population, including trips without a matching service status. Treat week-over-week change as the difference in completion rate from the previous available week for the same city.

Output

  1. One row per city and calendar week, with city, week_start, completion_rate, average_delay_minutes, and completion_rate_wow_change.
  2. Include cities and weeks represented in trip data, ordered by city and week_start.

Schema

trips
ColumnTypeDescription
trip_idPKINTUnique trip identifier
cityVARCHAR(80)City where the trip was requested
requested_atTIMESTAMPTrip request timestamp
service_status
ColumnTypeDescription
status_idPKINTUnique service status record identifier
trip_idINTReferenced trip identifier
service_statusVARCHAR(30)Operational outcome of the trip
delay_minutesDECIMAL(8,2)Recorded delay in minutes
updated_atTIMESTAMPStatus update timestamp
Tablestripsservice_status
Interviewer

Your question is SQL for City-Week Completion and Delay. 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.