Omnichannel Retail Analytics Path · Mission 9 of 25Medium

Ship-from-store rate by region

Conditional aggregation for ratio metrics. JOIN, GROUP BY region, ratio with NULLIF. The omnichannel mix lens every regional VP reviews quarterly.

Back to Omnichannel Retail Analytics

The Brief

Sofia ReyesVP Operationsops-leadership

Quarterly omnichannel review. By region: what pct of orders are store_ship_from_store vs total fulfilled orders (units > 0)? Four columns: region, total_orders, sfs_orders, sfs_pct. ROUND sfs_pct to 2 decimals. ORDER BY sfs_pct DESC, region ASC. Skip foot-traffic-no-purchase rows entirely (units > 0).

You'll practice

Conditional aggregationMulti-key GROUP BYRatio

Tables & columns available

fact_ordersfact10 columns
ColumnTypeKey
order_idINTPK
sku_idINTFK → dim_skus
store_idINTFK → dim_stores
channelTEXT
customer_zipTEXT
order_tsTEXT
unitsINT
gross_amountREAL
discount_amountREAL
fulfillment_costREAL
dim_storesdim7 columns
ColumnTypeKey
store_idINTPK
store_nameTEXT
regionTEXT
cityTEXT
stateTEXT
sq_ftINT
opened_dateTEXT

Hints (4)

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

Hint 1

JOIN fact_orders to dim_stores for region (web_ship orders won't join — they have store_id NULL).

Hint 2

Use INNER JOIN to drop web_ship from the count — the question is by-region.

Hint 3

Conditional aggregation: SUM(CASE WHEN channel = 'store_ship_from_store' THEN 1 ELSE 0 END) AS sfs_orders.

Hint 4

sfs_pct = 100.0 * sfs_orders / NULLIF(total_orders, 0), rounded.