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
Rank Steps with Window Functions
00:00
5 left

Rank Steps with Window Functions

MediumSQL · PostgreSQL

Problem

Write a SQL query using window functions to rank manufacturing steps by failure rate within each product line.

Use the provided manufacturing step and run records. Include defined steps with no runs, treating their failure rate as 0%.

Output

  1. One row per manufacturing step, with product_line, step_name, failure_rate, and step_rank.
  2. Rank steps within each product line by failure rate descending, with equal rates sharing a rank.
  3. Order by product_line, failure_rate descending, and step_name ascending.

Schema

manufacturing_steps
ColumnTypeDescription
step_idPKINTUnique manufacturing step identifier
product_lineVARCHAR(50)Product line containing the step
step_nameVARCHAR(100)Manufacturing step name
manufacturing_runs
ColumnTypeDescription
run_idPKINTUnique manufacturing run identifier
step_idINTManufacturing step evaluated by the run
run_dateDATEDate of the manufacturing run
statusVARCHAR(20)Run outcome, such as PASS or FAIL
Tablesmanufacturing_stepsmanufacturing_runs
Interviewer

Your question is Rank Steps with Window Functions. Start with the requirements and the two 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.