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
Clean Vehicle Delivery Timeline Records
00:00
5 left

Clean Vehicle Delivery Timeline Records

MediumSQL · PostgreSQL

Problem

You are given raw vehicle delivery timeline data with duplicate status events and missing milestone dates. Write a PostgreSQL query that returns one row per delivery for Lucid Air and Lucid Gravity vehicles, keeping only the latest record for each (delivery_id, event_type) pair, then summarizing the cleaned timeline. Your output should include the vehicle model, delivery center, order date, confirmed delivery date, the number of distinct event types captured, and a delivery status flag that marks a record as incomplete_timeline when either the order date or confirmed delivery date is missing.

Use the delivery center table so the result includes center names even if some deliveries have no matching cleaned event rows.

Schema

deliveries
ColumnTypeDescription
delivery_idPKINTUnique delivery record
vehicle_vinVARCHAR(20)Vehicle VIN
vehicle_modelVARCHAR(30)Vehicle model
delivery_center_idINTReference to delivery center
delivery_events
ColumnTypeDescription
event_idPKINTUnique raw event row
delivery_idINTReference to delivery
event_typeVARCHAR(30)Timeline milestone type
event_timestampTIMESTAMPTimestamp recorded for the milestone
delivery_centers
ColumnTypeDescription
delivery_center_idPKINTDelivery center ID
center_nameVARCHAR(50)Delivery center name
Tablesdeliveriesdelivery_eventsdelivery_centers
Interviewer

Your question is Clean Vehicle Delivery Timeline Records. Start with the requirements and the three 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.