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 Production Performance Analysis
00:00
5 left

SQL Production Performance Analysis

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze production performance by plant, line, and week, including output, defect rate, and on-time delivery rate.

Use the provided production, line, and delivery data. Include production weeks with no delivery records, and treat missing defect or delivery-status values appropriately.

Output

  1. One row per plant, line, and calendar week
  2. Columns: plant_name, line_name, week_start, total_output, defect_rate_pct, and on_time_delivery_rate_pct
  3. Include all production groups, order by plant, line, and week, and round percentage values to two decimal places

Schema

production_runs
ColumnTypeDescription
run_idPKINTProduction run identifier
line_idINTProduction line identifier
production_dateDATEDate of the production run
units_outputINTUnits produced during the run
defective_unitsINTUnits identified as defective
lines
ColumnTypeDescription
line_idPKINTProduction line identifier
plant_nameVARCHAR(100)Plant name
line_nameVARCHAR(100)Production line name
deliveries
ColumnTypeDescription
delivery_idPKINTDelivery identifier
run_idINTRelated production run identifier
on_timeBOOLEANWhether the delivery met its scheduled date
Tablesproduction_runslinesdeliveries
Interviewer

Your question is SQL Production Performance Analysis. 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.