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 Labor and Productivity
00:00
5 left

SQL for Labor and Productivity

MediumSQL · PostgreSQL

Problem

Write a SQL query to calculate weekly labor hours, average productivity, and variance from target by site.

Use the supplied tables and include every site-week with labor activity, including rows where no productivity target is available.

Output

  1. One row per site and calendar week, with site_name, week_start, total_labor_hours, average_productivity, target_productivity, and variance_from_target.
  2. Variance is average productivity minus target productivity. Sort by site name, then week start.

Schema

sites
ColumnTypeDescription
site_idPKINTUnique Tennessee Staffing site identifier
site_nameVARCHAR(100)Site display name
regionVARCHAR(50)Operating region for the site
labor_records
ColumnTypeDescription
labor_record_idPKINTUnique labor record identifier
site_idINTSite where the labor was recorded
work_dateDATEDate of the labor activity
hours_workedNUMERIC(6,2)Labor hours recorded
productivity_unitsNUMERIC(10,2)Productivity units recorded for the labor activity
site_productivity_targets
ColumnTypeDescription
target_idPKINTUnique target record identifier
site_idINTSite associated with the productivity target
target_productivityNUMERIC(10,2)Expected productivity units for the site
Tableslabor_recordssitessite_productivity_targets
Interviewer

Your question is SQL for Labor and Productivity. 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.