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

SQL for Missed Target Drivers

HardSQL · PostgreSQL

Problem

Write a SQL query to analyze production performance by plant, week, and product line, joining orders, inventory, and downtime tables to identify the biggest drivers of missed targets at Atlas Copco.

Return only plant and product-line weeks where produced units missed the target. Calculate inventory shortages and downtime impacts, identify the largest driver, and compare each shortfall with the previous week for that plant and product line.

Output

  1. One row per missed-target plant, week, and product line.
  2. Include plant, week_start, product_line, target_units, produced_units, shortfall_units, inventory_shortage_units, downtime_hours, primary_driver, plant_shortfall_rank, and shortfall_change_vs_prior_week.
  3. Order by plant, shortfall rank, week, and product line.

Schema

orders
ColumnTypeDescription
order_idPKINTUnique production order identifier
plantVARCHAR(100)Atlas Copco production plant
order_dateDATEDate associated with the production order
product_lineVARCHAR(100)Product line being produced
target_unitsINTUnits targeted for production
produced_unitsINTUnits actually produced
inventory
ColumnTypeDescription
inventory_idPKINTUnique inventory snapshot identifier
plantVARCHAR(100)Plant holding the inventory
inventory_dateDATEDate of the inventory snapshot
product_lineVARCHAR(100)Product line requiring inventory
available_unitsINTUnits available for production
required_unitsINTUnits required for planned production
downtime
ColumnTypeDescription
downtime_idPKINTUnique downtime event identifier
plantVARCHAR(100)Plant experiencing downtime
downtime_dateDATEDate of the downtime event
product_lineVARCHAR(100)Product line affected by downtime
downtime_reasonVARCHAR(100)Reason for the downtime event
downtime_hoursDECIMAL(8,2)Duration of the downtime event in hours
Tablesordersinventorydowntime
Interviewer

Your question is SQL for Missed Target 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.