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 Production Tracking
00:00
5 left

SQL for Production Tracking

MediumSQL · PostgreSQL

Problem

Write a SQL query to track weekly production volume, labor hours, and completion rate by site.

Use the provided production, labor, and site records. Calculate weekly results using Monday as the start of the week, include weeks with production activity, and treat missing labor hours as zero.

Output

  1. One row per site and production week.
  2. Columns: site_id, site_name, week_start, production_volume, labor_hours, and completion_rate.
  3. Include completion rate as a percentage, return NULL when planned production is zero, and order by site_id and week_start.

Schema

sites
ColumnTypeDescription
site_idPKINTUnique site identifier
site_nameVARCHAR(100)Site name
production_records
ColumnTypeDescription
production_idPKINTUnique production record identifier
site_idINTSite where production occurred
production_dateDATEProduction activity date
planned_unitsINTUnits planned for the production record
completed_unitsINTUnits completed
labor_logs
ColumnTypeDescription
labor_log_idPKINTUnique labor log identifier
site_idINTSite where labor was recorded
work_dateDATEDate labor was recorded
labor_hoursDECIMAL(8,2)Hours worked
Tablessitesproduction_recordslabor_logs
Interviewer

Your question is SQL for Production Tracking. 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.