Quick Commerce Analytics Path · Mission 6 of 25Medium

Pick-to-deliver time distribution

Bucket a continuous metric into quartiles with NTILE and summarize each bucket with COUNT and AVG. Practice excluding NULLs from incomplete dispatches.

Back to Quick Commerce Analytics

The Brief

Sam OkaforOperations Leadops

I want to understand our delivery-time spread, not just the average. Split completed dispatches into four equal quartiles by pick_to_deliver_minutes and show me the count and the average minutes in each. Skip rows where pick_to_deliver_minutes is NULL (those never delivered). Columns: quartile, dispatch_count, avg_minutes. ORDER BY quartile.

You'll practice

PercentileAVGNTILE

Tables & columns available

fact_shopper_dispatchesfact10 columns
ColumnTypeKey
dispatch_idINTPK
shopper_idINTFK → dim_shoppers
dispatch_tsTEXT
pickup_tsTEXT
deliver_tsTEXT
batch_sizeINT
pick_to_deliver_minutesINT
dispatch_statusTEXT
total_distance_miREAL
shopper_payoutREAL

Hints (4)

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

Hint 1

Only dispatches with a non-NULL pick_to_deliver_minutes count; filter those first.

Hint 2

NTILE(4) OVER (ORDER BY pick_to_deliver_minutes) labels each row 1-4 by speed.

Hint 3

Wrap that in a subquery, then GROUP BY quartile with COUNT(*) and ROUND(AVG(pick_to_deliver_minutes), 1).

Hint 4

ORDER BY quartile so the fastest bucket is first.