Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Trending in AI
Hot
Agentic AI EngineerForward-Deployed EngineerGenAI EngineerAI Architect
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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Start free
Warehouse Performance SQL Analysis
00:00
5 left

Warehouse Performance SQL Analysis

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze warehouse performance by site, shift, and day, including throughput, accuracy, and labor cost per unit. Use the provided warehouse, shift, and operation data. Include only valid site and shift combinations with positive processed units.

Output

  1. One row per site, shift, and operation date.
  2. Columns: site_name, shift_name, operation_date, throughput, accuracy_pct, and labor_cost_per_unit.
  3. Sort by site name, operation date, and shift name.

Output details

  • Compute throughput as the sum of units_processed for each site, shift, and operation date.
  • Compute accuracy_pct as 100 times summed accurate_units divided by summed units_processed, treating NULL accurate_units as 0.
  • Compute labor_cost_per_unit as summed labor_cost divided by summed units_processed, treating NULL labor_cost as 0.
  • Round accuracy_pct and labor_cost_per_unit to 2 decimal places.
  • Sort site_name, operation_date, and shift_name in ascending order.

Schema

warehouse_sites
ColumnTypeDescription
site_idPKINTUnique warehouse site identifier
site_nameVARCHAR(100)Warehouse site name
warehouse_shifts
ColumnTypeDescription
shift_idPKINTUnique shift identifier
shift_nameVARCHAR(50)Shift label
warehouse_operations
ColumnTypeDescription
operation_idPKINTUnique operation record identifier
site_idINTWarehouse site identifier
shift_idINTShift identifier
operation_dateDATEDate of the operation
units_processedINTUnits processed during the operation
accurate_unitsINTUnits processed accurately
labor_costDECIMAL(12,2)Labor cost for the operation
Tableswarehouse_siteswarehouse_shiftswarehouse_operations
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.