File size: 593 Bytes
27ec678
 
 
1
2
3
4
-- Share of storefront parcels by carrier
-- Storefront order parcels shipped in the window by carrier code, as shares of all of them.
SELECT coalesce(c.code, 'None') AS grp, count(*) AS parcels, count(*)::DOUBLE / sum(count(*)) OVER () AS value FROM (SELECT s.*, o.market_code, o.pincode_tier FROM logistics.shipment s JOIN commerce.order o USING (order_id) WHERE s.shipment_type = 'order' AND o.b2b_account_id IS NULL) p LEFT JOIN logistics.carrier c ON c.carrier_id = p.carrier_id WHERE p.shipped_at >= TIMESTAMP '2023-10-01' AND p.shipped_at < TIMESTAMP '2026-10-01' GROUP BY 1 ORDER BY 1