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 Join Schedules to Efficiency
00:00
5 left

SQL Join Schedules to Efficiency

MediumSQL · PostgreSQL

Problem

Write a SQL query to join staffing schedules, production output, and sales results to identify which shifts are most efficient. Use scheduled labor hours as scheduled hours multiplied by staff count. Treat production output per labor hour as the primary efficiency measure, with sales revenue per labor hour as a supporting metric. Exclude shifts with zero or unknown labor hours.

Output

  1. One row per eligible shift, including shifts without matching production or sales rows.
  2. Columns: shift_id, shift_date, shift_name, labor_hours, units_produced, total_defects, sales_revenue, production_per_labor_hour, sales_per_labor_hour, and efficiency_rank.
  3. Order by efficiency_rank, then shift_id.

Schema

staffing_schedules
ColumnTypeDescription
shift_idPKINTUnique shift identifier
shift_dateDATEDate of the scheduled shift
shift_nameVARCHAR(20)Shift label
scheduled_hoursDECIMAL(5,2)Hours scheduled for the shift
staff_countINTNumber of scheduled staff members
production_output
ColumnTypeDescription
output_idPKINTUnique production record identifier
shift_idINTShift associated with the production record
units_producedINTUnits produced in the record
defect_countINTDefective units recorded
sales_results
ColumnTypeDescription
sales_idPKINTUnique sales record identifier
shift_idINTShift associated with the sales record
sales_revenueDECIMAL(12,2)Revenue attributed to the shift
order_countINTOrders attributed to the shift
Tablesstaffing_schedulesproduction_outputsales_results
Interviewer

Your question is SQL Join Schedules to Efficiency. 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.