First Pass Yield by Work Center From Factory Inspection Records
Last updated: November 29, 2026
Quick Overview
Given an `inspections` table of `(inspection_id, part_serial, work_center, inspected_at, result)`, compute for each work center and week the share of parts that passed on their first inspection at that work center.
Spacex
November 29, 20260
0
0 solved
Given an `inspections` table of `(inspection_id, part_serial, work_center, inspected_at, result)`, compute for each work center and week the share of parts that passed on their first inspection at that work center.
SpaceX builds most hardware in house, and factory software teams track part traceability and quality for welds, machined parts and avionics boards. This screen checks window functions, defining the metric correctly (first attempt per part per work center), and weekly bucketing.
What the Interviewer Expects
- Clarify that re-inspections after rework must not inflate yield
- Use ROW_NUMBER partitioned by part and work center to find the first attempt
- Break ties on identical timestamps deterministically
- Bucket by week of the first attempt, not of the latest attempt
- Return counts alongside the ratio so small samples are visible
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you compute rolled throughput yield across a sequence of work centers?
- How would you flag a work center whose yield dropped sharply versus its trailing four weeks?
- What indexes would you add for this query on a table with a billion rows?
- How do you treat parts that were scrapped without a second inspection?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
One row per inspection event. A part can be inspected several times at the same work center after rework, and visits several work centers. result is PASS or FAIL. First pass yield for a work cen...
Approach
Rank inspections within (part_serial, work_center) by time, keep attempt 1, flag pass, then aggregate by work center and week. Tie-break on inspection_id so two events at the same timestamp give a...