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 Output and Defects
00:00
5 left

SQL for Output and Defects

MediumSQL · PostgreSQL

Problem

Write a SQL query to track production output, downtime, and defect rates by shift and site, and summarize the results by week at Amgen.

Use production records with valid site and shift references. Defect rate is defective units divided by produced units, expressed as a percentage.

Output

  1. One row per site, shift, and week.
  2. Return site_name, shift_name, week_start, total_units_produced, total_downtime_minutes, and defect_rate_percent.
  3. Exclude records without a matching site or shift, order by site name, shift name, and week start, and round the defect rate to two decimal places.

Schema

sites
ColumnTypeDescription
site_idPKINTUnique Amgen manufacturing site identifier
site_nameVARCHAR(100)Amgen site name
shifts
ColumnTypeDescription
shift_idPKINTUnique shift identifier
shift_nameVARCHAR(50)Operational shift name
production_records
ColumnTypeDescription
production_idPKINTUnique production record identifier
site_idINTReferenced manufacturing site
shift_idINTReferenced operational shift
production_dateDATEDate of production activity
units_producedINTUnits produced during the record period
downtime_minutesINTDowntime measured in minutes
units_defectiveINTUnits identified as defective
Tablessitesshiftsproduction_records
Interviewer

Your question is SQL for Output and Defects. 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.