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 Query for Cycle-Time Bottlenecks
00:00
5 left

SQL Query for Cycle-Time Bottlenecks

MediumSQL · PostgreSQL

Problem

Write a business-flavored SQL query to identify production bottlenecks by analyzing cycle times across different manufacturing stages.

Use the provided production_runs, stage_cycles, and manufacturing_stages tables. Include only completed runs and completed cycles with non-null start and end timestamps.

Output

  1. One row per manufacturing stage with at least one qualifying cycle
  2. Columns: stage_id, stage_name, completed_cycle_count, avg_cycle_hours, max_cycle_hours, and bottleneck_rank
  3. Rank stages by average cycle time in descending order, with tied stages sharing a rank
  4. Order by bottleneck_rank, then stage_id

Schema

production_runs
ColumnTypeDescription
run_idPKINTUnique production run identifier
product_codeVARCHAR(30)Product or system code manufactured in the run
started_atTIMESTAMPProduction run start timestamp
completed_atTIMESTAMPProduction run completion timestamp
statusVARCHAR(20)Production run status
manufacturing_stages
ColumnTypeDescription
stage_idPKINTUnique manufacturing stage identifier
stage_nameVARCHAR(80)Manufacturing stage name
sequence_noINTSequence of the stage in the manufacturing flow
areaVARCHAR(60)Manufacturing area containing the stage
stage_cycles
ColumnTypeDescription
cycle_idPKINTUnique stage cycle identifier
run_idINTProduction run containing the stage cycle
stage_idINTManufacturing stage associated with the cycle
started_atTIMESTAMPStage cycle start timestamp
ended_atTIMESTAMPStage cycle end timestamp
statusVARCHAR(20)Stage cycle status
Tablesproduction_runsstage_cyclesmanufacturing_stages
Interviewer

Your question is SQL Query for Cycle-Time Bottlenecks. 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.