Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL for Operational Bottleneck Analysis
00:00
5 left

SQL for Operational Bottleneck Analysis

HardSQL · PostgreSQL

Problem

Write a SQL query to analyze operational performance by region and month, joining orders, shipments, and returns tables to identify bottlenecks.

Use the available records for all orders, including orders without shipments or returns. Define a bottleneck using shipment coverage, average delivery time, and return rate.

Output

  1. One row per region and order month.
  2. Columns: region, month, orders_count, shipped_orders, returned_orders, shipment_rate_pct, return_rate_pct, avg_delivery_days, bottleneck_score, bottleneck_reason, and prior_month_score.
  3. Include all order months, sort by region and month, and use NULL when a region has no prior month.

Schema

orders
ColumnTypeDescription
order_idPKINTUnique order identifier
regionVARCHAR(20)Operational region for the order
order_dateDATEDate the order was placed
shipments
ColumnTypeDescription
shipment_idPKINTUnique shipment identifier
order_idINTOrder associated with the shipment
shipped_atTIMESTAMPTimestamp when the shipment left the facility
delivered_atTIMESTAMPTimestamp when the shipment was delivered
returns
ColumnTypeDescription
return_idPKINTUnique return identifier
order_idINTOrder associated with the return
returned_atDATEDate the return was recorded
return_reasonVARCHAR(40)Reason provided for the return
Tablesordersshipmentsreturns
Interviewer

Your question is SQL for Operational Bottleneck Analysis. 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.