Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
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 feedbackSuccess 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
Top Yield Batches by Fab
00:00
5 left

Top Yield Batches by Fab

MediumSQL · PostgreSQL

Problem

Write a SQL query using window functions to identify the top three highest-yielding manufacturing batches for each fab location over the last quarter.

For this exercise, treat the last quarter as April 1, 2026 through June 30, 2026. Calculate yield as good units divided by tested units, exclude incomplete or invalid yield records, and use batch ID as the tie-breaker.

Output

  1. One row per selected batch, with fab_location, batch_id, completed_at, yield_rate, and yield_rank.
  2. Include no more than three batches per fab location, ordered by location and yield rank.

Schema

fab_locations
ColumnTypeDescription
fab_codePKVARCHAR(10)Unique fab code
location_nameVARCHAR(100)Fab location name
regionVARCHAR(50)Geographic region
production_batches
ColumnTypeDescription
batch_idPKINTUnique manufacturing batch identifier
fab_codeVARCHAR(10)Fab where the batch was produced
completed_atDATEBatch completion date
batch_statusVARCHAR(20)Production status
batch_metrics
ColumnTypeDescription
batch_idPKINTManufacturing batch identifier
tested_unitsINTUnits tested for the batch
good_unitsINTUnits passing quality tests
Tablesfab_locationsproduction_batchesbatch_metrics
Interviewer

Your question is Top Yield Batches by Fab. 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.