Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.