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

SQL for Hub Performance

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze hub performance by joining orders, deliveries, and inventory tables to calculate daily delivery TAT, wastage percentage, and stock-out rate.

Use completed deliveries for TAT, inventory quantities for wastage, and stock-out minutes over a 24-hour operating day. Include dates represented by any source table.

Output

  1. One row per hub and calendar date.
  2. Columns: hub_id, performance_date, avg_delivery_tat_minutes, wastage_percentage, and stock_out_rate.
  3. Include available hub-date combinations even when one metric has no source data. Sort by hub_id, then performance_date.

Schema

orders
ColumnTypeDescription
order_idPKINTUnique order identifier
hub_idVARCHAR(10)Fulfillment hub identifier
order_dateDATEDate the order was placed
deliveries
ColumnTypeDescription
delivery_idPKINTUnique delivery identifier
order_idINTRelated order identifier
dispatched_atTIMESTAMPTimestamp when the delivery was dispatched
delivered_atTIMESTAMPTimestamp when the order was delivered
statusVARCHAR(20)Delivery status
inventory
ColumnTypeDescription
inventory_idPKINTUnique inventory record identifier
hub_idVARCHAR(10)Inventory hub identifier
inventory_dateDATEInventory measurement date
opening_stockINTUnits available at the start of the day
received_qtyINTUnits received during the day
wastage_qtyINTUnits discarded during the day
stockout_minutesINTMinutes without available stock
Tablesordersdeliveriesinventory
Interviewer

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