Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL Joins for Fulfillment Metrics
00:00
5 left

SQL Joins for Fulfillment Metrics

MediumSQL · PostgreSQL

Problem

Write a SQL query using joins to combine orders, shipments, and inventory tables and calculate fulfillment metrics.

Return one row per order. Count all shipment records, but include quantities only from shipments with Shipped or Delivered status. Treat missing shipment quantities as zero and preserve orders without shipments or inventory.

Output

  1. Columns: order_id, sku, ordered_qty, shipment_count, shipped_qty, inventory_qty, fulfillment_percentage, fulfillment_status
  2. Sort by order_id ascending.
  3. Use No units required, Fulfilled, Partially fulfilled, or Unfulfilled for the fulfillment status.

Schema

orders
ColumnTypeDescription
order_idPKINTUnique customer order identifier
skuVARCHAR(20)Stock keeping unit ordered
ordered_qtyINTQuantity requested in the order
order_dateDATEDate the order was created
shipments
ColumnTypeDescription
shipment_idPKINTUnique shipment identifier
order_idINTOrder associated with the shipment
shipped_qtyINTQuantity assigned to this shipment
statusVARCHAR(20)Shipment processing status
shipped_dateDATEDate the shipment left the facility
inventory
ColumnTypeDescription
inventory_idPKINTUnique inventory record identifier
skuVARCHAR(20)Stock keeping unit held in inventory
warehouse_codeVARCHAR(10)Warehouse holding the inventory
on_hand_qtyINTCurrent available inventory quantity
Tablesordersshipmentsinventory
Interviewer

Your question is SQL Joins for Fulfillment Metrics. 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.