Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Monthly Studio Delivery Performance

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

Your question is Monthly Studio Delivery Performance. 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

You are given delivery event data for Lucid Studios and asked to analyze monthly delivery performance by studio. Write a PostgreSQL query that returns one row per studio per delivery month, showing the average dwell time in hours and the on-time delivery rate. Treat dwell time as the time between vehicle arrival at the studio and customer handoff. A delivery is on time when the actual handoff date is on or before the scheduled delivery date. Only include deliveries that were completed and have a non-null actual handoff timestamp.

Schema

lucid_studios
ColumnTypeDescription
studio_idPKINTPrimary key for each Lucid Studio
studio_nameVARCHAR(100)Studio name
regionVARCHAR(50)Studio region
vehicle_deliveries
ColumnTypeDescription
delivery_idPKINTPrimary key for each delivery
studio_idINTStudio handling the delivery
order_idINTCustomer order identifier
scheduled_delivery_dateDATEPlanned customer delivery date
actual_handoff_tsTIMESTAMPActual customer handoff timestamp
delivery_statusVARCHAR(30)Delivery status
delivery_events
ColumnTypeDescription
event_idPKINTPrimary key for each event
delivery_idINTRelated delivery
event_typeVARCHAR(40)Event type such as vehicle_arrived
event_tsTIMESTAMPEvent timestamp
Tableslucid_studiosvehicle_deliveriesdelivery_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results