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 Delay Drivers
00:00
5 left

SQL for Delay Drivers

HardSQL · PostgreSQL

Problem

Write a SQL query to analyze operational performance by site and month, joining work orders, staffing, and SLA tables to identify the biggest drivers of delay.

Return completed work orders that finished after their due time, classify SLA breaches using the applicable priority target, and include monthly staffing data when available.

Output

  1. One row per site, month, and delay reason, ranked by total delay hours within each site and month.
  2. Columns: site, month, delay_reason, delayed_orders, total_delay_hours, avg_delay_hours, sla_breach_rate, actual_staff_hours, driver_rank.
  3. Sort by site, month, and driver_rank ascending. Treat missing delay reasons as Unspecified.

Schema

work_orders
ColumnTypeDescription
work_order_idPKINTUnique work order identifier
siteVARCHAR(100)Operational site
opened_atTIMESTAMPTime the work order was opened
completed_atTIMESTAMPCompletion time, null for open work orders
due_atTIMESTAMPRequired completion time
priorityVARCHAR(20)Priority used to find the SLA target
delay_reasonVARCHAR(100)Reported primary cause of delay
staffing_monthly
ColumnTypeDescription
staffing_idPKINTUnique staffing record identifier
siteVARCHAR(100)Operational site
monthDATEFirst day of the staffing month
planned_staff_hoursNUMERIC(10,2)Planned staffing hours
actual_staff_hoursNUMERIC(10,2)Actual staffing hours worked
sla_targets
ColumnTypeDescription
priorityPKVARCHAR(20)Work order priority
target_hoursNUMERIC(10,2)Maximum allowed completion duration in hours
Tableswork_ordersstaffing_monthlysla_targets
Interviewer

Your question is SQL for Delay Drivers. 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.