Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Analyzing Operations Bottlenecks with SQL

HardSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Analyzing Operations Bottlenecks with SQL. Start with the requirements and the three tables on the right.

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.

Problem

Business Context

Samsung Electronics operations leaders need a daily view of regional fulfillment performance across orders, inventory, and shipments. The analysis should distinguish delivery delays from inventory constraints and missing operational data.

Task

Write a PostgreSQL query that analyzes orders placed in January 2025 by region and order date.

Requirements

  1. Use the most recent inventory snapshot on or before each order date, without duplicating orders.
  2. Use a LEFT JOIN for shipments so unshipped orders remain visible, and classify orders as late when delivery exceeded the promised date or was still missing on February 1, 2025.
  3. Report order count, late orders, late-delivery percentage, inventory-shortage orders, orders with unavailable inventory data, and average delivery days.
  4. Use LAG to show the previous available day's late-delivery percentage for the same region.
  5. Return one row per region and order date, ordered by region and date.

Schema

orders
ColumnTypeDescription
order_idPKINTUnique order identifier
regionVARCHAR(40)Samsung sales or fulfillment region
product_idVARCHAR(20)Product identifier
warehouse_idVARCHAR(20)Fulfillment warehouse identifier
order_dateDATEDate the order was placed
promised_dateDATEPromised delivery date
quantityINTUnits ordered
inventory_snapshots
ColumnTypeDescription
inventory_snapshot_idPKINTUnique inventory snapshot identifier
product_idVARCHAR(20)Product identifier
warehouse_idVARCHAR(20)Warehouse identifier
snapshot_dateDATEDate inventory was recorded
available_qtyINTUnits available at the snapshot
shipments
ColumnTypeDescription
shipment_idPKINTUnique shipment identifier
order_idINTRelated order identifier
shipped_dateDATEDate shipment left the warehouse
delivered_dateDATEDate shipment was delivered
carrierVARCHAR(40)Shipping carrier
Tablesordersinventory_snapshotsshipments
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results