Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL for Warehouse Performance
00:00
5 left

SQL for Warehouse Performance

MediumSQL · PostgreSQL

Problem

Write a SQL query to analyze warehouse performance at Sysco by joining shipment, inventory, and labor tables to calculate cases per hour and dock-to-stock time by facility. Use the supplied tables and include facilities appearing in any source table. Handle missing values and zero labor hours without causing errors.

Output

  1. One row per facility, including facilities without matching records in another table.
  2. Columns: facility_id, shipped_cases, labor_hours, cases_per_hour, and avg_dock_to_stock_minutes.
  3. Round calculated metrics to two decimal places, sort by facility_id ascending, and return NULL when a metric cannot be calculated.

Schema

shipments
ColumnTypeDescription
shipment_idPKINTUnique shipment identifier
facility_idVARCHAR(10)Sysco warehouse facility identifier
shipped_atTIMESTAMPShipment completion timestamp
cases_shippedINTNumber of cases shipped
inventory_events
ColumnTypeDescription
event_idPKINTUnique inventory event identifier
facility_idVARCHAR(10)Sysco warehouse facility identifier
received_atTIMESTAMPTimestamp when inventory arrived at the dock
stocked_atTIMESTAMPTimestamp when inventory was placed into stock
cases_receivedINTNumber of cases received
labor_shifts
ColumnTypeDescription
shift_idPKINTUnique labor shift identifier
facility_idVARCHAR(10)Sysco warehouse facility identifier
shift_dateDATEDate of the labor shift
hours_workedDECIMAL(6,2)Labor hours recorded for the shift
Tablesshipmentsinventory_eventslabor_shifts
Interviewer

Your question is SQL for Warehouse 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.