Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Rank Facilities by Cycle Time

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Rank Facilities by Cycle Time. Start with the requirements and the three tables on the right.

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.

Problem

You are given manufacturing data for assembly runs across facilities and product lines. Write a PostgreSQL query that returns each facility’s average assembly cycle time for every product line, then ranks facilities within each product line from fastest to slowest using a window function. Only include completed runs, and use the product line name in the final output.

Schema

assembly_runs
ColumnTypeDescription
run_idPKINTUnique assembly run identifier
facility_idINTFacility where the assembly run occurred
product_line_idINTProduct line associated with the run
cycle_time_minutesNUMERIC(8,2)Assembly cycle time in minutes
run_statusVARCHAR(20)Status of the run
facilities
ColumnTypeDescription
facility_idPKINTUnique facility identifier
facility_nameVARCHAR(100)Facility name
product_lines
ColumnTypeDescription
product_line_idPKINTUnique product line identifier
product_line_nameVARCHAR(100)Product line name
Tablesassembly_runsfacilitiesproduct_lines
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results