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 for Site Performance
00:00
5 left

SQL for Site Performance

HardSQL · PostgreSQL

Problem

Write an SQL query to analyze monthly operational performance by site, joining production, downtime, and staffing tables to identify the top underperforming locations.

Calculate performance using units produced per staffed hour. Include downtime as a supporting operational metric, and return the two lowest-performing sites for each month. Treat missing downtime as zero and use site ID to break performance ties.

Output

  1. One row per selected site and month with month_start, site_id, units_produced, downtime_hours, staffed_hours, units_per_staffed_hour, and underperformance_rank.
  2. Include up to two sites per month, ordered by month_start, then underperformance_rank, then site_id.

Schema

production
ColumnTypeDescription
production_idPKINTUnique production record identifier
site_idINTOperational site identifier
production_dateDATEDate of production activity
units_producedINTNumber of units produced
downtime
ColumnTypeDescription
downtime_idPKINTUnique downtime record identifier
site_idINTOperational site identifier
downtime_dateDATEDate downtime was recorded
downtime_hoursNUMERIC(8,2)Hours of downtime recorded
staffing
ColumnTypeDescription
staffing_idPKINTUnique staffing record identifier
site_idINTOperational site identifier
staffing_dateDATEDate staffed hours were recorded
staffed_hoursNUMERIC(8,2)Total employee hours assigned
Tablesproductiondowntimestaffing
Interviewer

Your question is SQL for Site Performance. 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.