Quick Commerce Analytics Path · Mission 8 of 25Medium

Shopper completion rate

Compute a rate with conditional aggregation (AVG of a CASE) and handle the NULL-shopper rows that represent undispatched orders.

Back to Quick Commerce Analytics

The Brief

Priya NairShopper Operations Leadshopper-ops

Quarterly shopper reviews. I need a completion rate per shopper: of the orders assigned to them, what share ended up delivered? Use fact_orders.order_status. Ignore orders with no shopper assigned (shopper_id IS NULL). Columns: shopper_id, completion_rate (4 decimals). ORDER BY completion_rate DESC, shopper_id ASC.

You'll practice

Conditional aggregationRatioGROUP BY shopper

Tables & columns available

fact_ordersfact18 columns
ColumnTypeKey
order_idINTPK
customer_idINTFK → dim_customers
merchant_idINTFK → dim_merchants
shopper_idINTFK → dim_shoppers
dispatch_idINTFK → fact_shopper_dispatches
order_tsTEXT
order_statusTEXT
unitsINT
item_subtotalREAL
delivery_feeREAL
service_feeREAL
surge_feeREAL
surge_multiplierREAL
tip_amountREAL
customer_totalREAL
shopper_takeREAL
platform_takeREAL
merchant_payoutREAL

Hints (3)

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

Hint 1

An order counts as completed when order_status = 'delivered'.

Hint 2

A delivered/not-delivered flag (1 or 0) averaged across a shopper's orders is their completion rate: reach for AVG over a CASE expression, and make the 'yes' value 1.0 so you don't fall into integer division.

Hint 3

Filter WHERE shopper_id IS NOT NULL, GROUP BY shopper_id, ROUND to 4 decimals.