Operations & Supply Chain Analytics · Mission 11 of 30Medium

Average lead time per supplier

Date arithmetic + GROUP BY AVG; filter NULL actual_arrival.

The Brief

Raj PatelProcurement Managerslack-dm

For the supplier review: average lead time per supplier in days. Lead time = `actual_arrival - order_date` for received POs. Skip in-flight orders (NULL actual_arrival) and cancelled ones — only count POs we actually got delivered. Return supplier_name and avg_lead_time_days. Round to 1 decimal so the slide reads cleanly.

You'll practice

Date arithmeticGROUP BY AVGNULL filter

Tables & columns available

fact_purchase_ordersfact12 columns
ColumnTypeKey
po_idINTPK
po_numberTEXT
sku_idINTFK → dim_skus
supplier_idINTFK → dim_suppliers
warehouse_idINTFK → dim_warehouses
order_dateTEXT
expected_arrivalTEXT
actual_arrivalTEXT
qty_orderedINT
qty_receivedINT
unit_costREAL
statusTEXT
dim_suppliersdim6 columns
ColumnTypeKey
supplier_idINTPK
supplier_nameTEXT
countryTEXT
lead_time_target_daysINT
on_time_target_pctREAL
is_activeINT

Hints (3)

Each hint you reveal reduces the XP you can earn. Try the query first.

Hint 1

JOIN `fact_purchase_orders` to `dim_suppliers` ON `supplier_id`. Filter `status = 'received'` to drop cancelled and in-flight POs.

Hint 2

Lead time per row = `julianday(actual_arrival) - julianday(order_date)` (SQLite) or `actual_arrival::date - order_date::date` (Postgres).

Hint 3

GROUP BY supplier_name, AVG(lead_time_days), ROUND(..., 1). ORDER BY avg_lead_time_days DESC for readability.