Queries · q243 · Chief Operating Officer · week 2, night 4
“Confirmed and reconciled: how much does Lowlands Express's order-level reliability differ between its home lanes (Netherlands/Belgium/France) and everywhere else, versus the rest of our carriers combined?”
Fictional people at a fictional company, each played by a language-model agent. Who they are and what they are told
The manager, at the start of week 2
Subject: Carrier picture confirms it — now I want to know what we can actually fix
Lena,
This is exactly the clarity I was hoping for — "it's the carriers, not the warehouses" is a much more actionable story than "fulfillment is inconsistent." A few things jumped out, including from what Daniel's and Tomasz's teams posted this week, and I want to chase them down before we draft anything for merchants or carrier partners.
What surprised me: Albion Parcel going from solid to broken in November and staying broken through December is different from Landfall and Lowlands, which sound like long-term weak performers we've just tolerated. One is a relationship we may need to end; the other looks like it could be an acute problem (capacity, a route, a depot) that might actually be fixable if we understood the trigger. I don't want to lump all three into one "bad carriers" conversation when they may need completely different responses.
I also noticed Daniel's team's finding that "where's my order" tickets spike in lockstep with late deliveries each November/December — that's a direct line from the carrier problem to support cost and customer satisfaction, and I'd like to be able to say that explicitly in my own numbers rather than borrowing his.
Questions for this week:
If it's a tight week, prioritize #1 and #2 — I want the carrier narrative airtight before I take it anywhere. Returns/restock cycle time can wait one more week if needed.
Thanks, Priya
The analyst · week 2, night 4, request 3 of 3
Before I write anything, I cross-checked the three night-3 order-level reports against each other by hand, and they don't reconcile: Report 1 says the three weak carriers blend to 66.8% within 5 days; Report 2's Albion baseline/collapse figures imply Albion alone blends to ~80.1%, which would force Landfall+Lowlands down to ~58.8% to match Report 1's total. But Report 3's "all other carriers" (82.0%, 18,088 orders) combined with Report 1's "good eleven" (93.4%, 13,696 orders) and Report 2's Albion (~80.1%, 2,564 orders) overshoots the reported total on its own -- it would require Landfall's own rate to be negative, which is impossible. So at least one of these three reports has an inconsistency (likely a scoping or computation difference across the three separate queries), and I'm not willing to hand Priya a "ceiling" number or a "fix Lowlands' lanes" recommendation until it's resolved -- this is exactly the kind of number I'd expect her or Daniel's/Tomasz's teams to poke at. Tonight (last night) I'm spending all 3 slots getting a single, internally-consistent source of truth in one query each, rather than stitching across reports: (1) one full-year carrier-level breakdown to anchor the ceiling calculation, (2) one carrier-group-by-quarter breakdown (Albion / Landfall / Lowlands / everyone else) to nail down the timing story cleanly, and (3) one Lowlands-by-lane breakdown done the same consistent way, so the lane-reassignment number is trustworthy. I'll reconcile against this week's earlier reports once these are back and flag any remaining discrepancy explicitly in the memo rather than paper over it.
The engineer · 1 dry run on the empty schema, then the submission
WITH order_fulfillment_counts AS ( SELECT order_id, COUNT(*) AS fulfillment_count FROM fulfillments GROUP BY order_id ), fulfillment_shipment_counts AS ( SELECT fulfillment_id, COUNT(*) AS shipment_count FROM shipments GROUP BY fulfillment_id ), eligible_orders AS ( SELECT o.id AS order_id, o.placed_at, o.shipping_address_id, f.id AS fulfillment_id FROM orders o JOIN order_fulfillment_counts ofc ON ofc.order_id = o.id AND ofc.fulfillment_count = 1 JOIN fulfillments f ON f.order_id = o.id WHERE o.status = 'fulfilled' AND o.placed_at >= DATE '2025-01-01' AND o.placed_at < DATE '2026-01-01' ), eligible_with_shipment AS ( SELECT eo.order_id, eo.placed_at, eo.shipping_address_id, s.carrier, s.delivered_at FROM eligible_orders eo JOIN fulfillment_shipment_counts fsc ON fsc.fulfillment_id = eo.fulfillment_id AND fsc.shipment_count = 1 JOIN shipments s ON s.fulfillment_id = eo.fulfillment_id WHERE s.delivered_at IS NOT NULL ), order_lane AS ( SELECT ews.order_id, EXTRACT(EPOCH FROM (ews.delivered_at - ews.placed_at)) / 86400.0 AS delivery_days, CASE WHEN ews.carrier = 'Lowlands Express' AND c.name IN ('Netherlands', 'Belgium', 'France') THEN 'Lowlands core (NL/BE/FR)' WHEN ews.carrier = 'Lowlands Express' THEN 'Lowlands non-core (other countries)' ELSE 'All other carriers combined' END AS lane_group FROM eligible_with_shipment ews LEFT JOIN addresses a ON a.id = ews.shipping_address_id LEFT JOIN countries c ON c.id = a.country_id ), lane_groups AS ( SELECT 'Lowlands core (NL/BE/FR)' AS lane_group, 1 AS sort_order UNION ALL SELECT 'Lowlands non-core (other countries)', 2 UNION ALL SELECT 'All other carriers combined', 3 ), lane_stats AS ( SELECT lane_group, COUNT(*) AS orders_fully_delivered, AVG(delivery_days) AS avg_delivery_days, AVG(CASE WHEN delivery_days <= 5 THEN 1.0 ELSE 0.0 END) * 100 AS pct_within_5_days FROM order_lane GROUP BY lane_group ), totals AS ( SELECT SUM(orders_fully_delivered) AS total_orders FROM lane_stats ) SELECT lg.lane_group, COALESCE(ls.orders_fully_delivered, 0) AS orders_fully_delivered, ROUND(CAST(ls.avg_delivery_days AS numeric), 2) AS avg_delivery_days, ROUND(CAST(ls.pct_within_5_days AS numeric), 1) AS pct_within_5_days, ROUND(CAST(COALESCE(ls.orders_fully_delivered, 0) AS numeric) / NULLIF(t.total_orders, 0) * 100, 1) AS share_of_orders_pct FROM lane_groups lg LEFT JOIN lane_stats ls ON ls.lane_group = lg.lane_group CROSS JOIN totals t ORDER BY lg.sort_order
“Query compiles and returns the expected columns. Submitting.”
“Submitted. The report splits the fully-delivered, single-shipment 2025 order population into the three requested lane groups (Lowlands core, Lowlands non-core, all other carriers), with counts, average delivery days, % within 5 days, and share of total — using the identical eligibility filter as the other reports in this batch so the totals should reconcile.”
As Lena Hartmann saw it, from the small dataset the agents worked on
lane_group | orders_fully_delivered | avg_delivery_days | pct_within_5_days | share_of_orders_pct ------------------------------------+------------------------+-------------------+-------------------+-------------------- Lowlands core (NL/BE/FR) | 1581 | 4.34 | 72.9 | 7.7 Lowlands non-core (other countries) | 864 | 5.96 | 34.1 | 4.2 All other carriers combined | 18088 | 3.92 | 82.0 | 88.1 (3 rows)
The memo and the queries that followed; links found by title, so inferred
It builds on:
Changed only where the benchmark needs the same result on every system
WITH order_fulfillment_counts AS ( SELECT order_id, COUNT(*) AS fulfillment_count FROM fulfillments GROUP BY order_id),fulfillment_shipment_counts AS ( SELECT fulfillment_id, COUNT(*) AS shipment_count FROM shipments GROUP BY fulfillment_id),eligible_orders AS ( SELECT o.id AS order_id, o.placed_at, o.shipping_address_id, o.placed_at AS placed_at, o.shipping_address_id AS shipping_address_id, f.id AS fulfillment_id FROM orders o JOIN order_fulfillment_counts ofc ON ofc.order_id = o.id AND ofc.fulfillment_count = 1 JOIN fulfillments f ON f.order_id = o.id WHERE o.status = 'fulfilled' AND o.placed_at >= DATE '2025-01-01' AND o.placed_at < DATE '2026-01-01'),eligible_with_shipment AS ( SELECT eo.order_id, eo.placed_at, eo.shipping_address_id, s.carrier, s.delivered_at eo.order_id AS order_id, eo.placed_at AS placed_at, eo.shipping_address_id AS shipping_address_id, s.carrier AS carrier, s.delivered_at AS delivered_at FROM eligible_orders eo JOIN fulfillment_shipment_counts fsc ON fsc.fulfillment_id = eo.fulfillment_id AND fsc.shipment_count = 1 JOIN shipments s ON s.fulfillment_id = eo.fulfillment_id WHERE s.delivered_at IS NOT NULL),order_lane AS ( SELECT ews.order_id, EXTRACT(EPOCH FROM (ews.delivered_at - ews.placed_at)) / 86400.0 AS delivery_days, ews.order_id AS order_id, {{seconds_between(ews.placed_at, ews.delivered_at)}} / 86400.0 AS delivery_days, CASE WHEN ews.carrier = 'Lowlands Express' AND c.name IN ('Netherlands', 'Belgium', 'France') THEN 'Lowlands core (NL/BE/FR)' WHEN ews.carrier = 'Lowlands Express' THEN 'Lowlands non-core (other countries)' ELSE 'All other carriers combined' END AS lane_group FROM eligible_with_shipment ews LEFT JOIN addresses a ON a.id = ews.shipping_address_id LEFT JOIN countries c ON c.id = a.country_id),lane_groups AS ( SELECT 'Lowlands core (NL/BE/FR)' AS lane_group, 1 AS sort_order UNION ALL SELECT 'Lowlands non-core (other countries)', 2 UNION ALL SELECT 'All other carriers combined', 3),lane_stats AS ( SELECT lane_group, COUNT(*) AS orders_fully_delivered, AVG(delivery_days) AS avg_delivery_days, AVG(CASE WHEN delivery_days <= 5 THEN 1.0 ELSE 0.0 END) * 100 AS pct_within_5_days FROM order_lane GROUP BY lane_group),totals AS ( SELECT SUM(orders_fully_delivered) AS total_orders FROM lane_stats)SELECT lg.lane_group, lg.lane_group AS lane_group, COALESCE(ls.orders_fully_delivered, 0) AS orders_fully_delivered, ROUND(CAST(ls.avg_delivery_days AS numeric), 2) AS avg_delivery_days, ROUND(CAST(ls.pct_within_5_days AS numeric), 1) AS pct_within_5_days, ROUND(CAST(COALESCE(ls.orders_fully_delivered, 0) AS numeric) / NULLIF(t.total_orders, 0) * 100, 1) AS share_of_orders_pct ls.avg_delivery_days AS avg_delivery_days, ls.pct_within_5_days AS pct_within_5_days, CAST(COALESCE(ls.orders_fully_delivered, 0) AS numeric(18,6)) / NULLIF(t.total_orders, 0) * 100 AS share_of_orders_pctFROM lane_groups lgLEFT JOIN lane_stats ls ON ls.lane_group = lg.lane_groupCROSS JOIN totals tORDER BY lg.sort_orderORDER BY lg.sort_order NULLS LAST
WITH order_fulfillment_counts AS ( SELECT order_id, COUNT(*) AS fulfillment_count FROM fulfillments GROUP BY order_id ), fulfillment_shipment_counts AS ( SELECT fulfillment_id, COUNT(*) AS shipment_count FROM shipments GROUP BY fulfillment_id ), eligible_orders AS ( SELECT o.id AS order_id, o.placed_at AS placed_at, o.shipping_address_id AS shipping_address_id, f.id AS fulfillment_id FROM orders o JOIN order_fulfillment_counts ofc ON ofc.order_id = o.id AND ofc.fulfillment_count = 1 JOIN fulfillments f ON f.order_id = o.id WHERE o.status = 'fulfilled' AND o.placed_at >= DATE '2025-01-01' AND o.placed_at < DATE '2026-01-01' ), eligible_with_shipment AS ( SELECT eo.order_id AS order_id, eo.placed_at AS placed_at, eo.shipping_address_id AS shipping_address_id, s.carrier AS carrier, s.delivered_at AS delivered_at FROM eligible_orders eo JOIN fulfillment_shipment_counts fsc ON fsc.fulfillment_id = eo.fulfillment_id AND fsc.shipment_count = 1 JOIN shipments s ON s.fulfillment_id = eo.fulfillment_id WHERE s.delivered_at IS NOT NULL ), order_lane AS ( SELECT ews.order_id AS order_id, CAST(EXTRACT(EPOCH FROM (ews.delivered_at - ews.placed_at)) AS NUMERIC(18,6)) / 86400.0 AS delivery_days, CASE WHEN ews.carrier = 'Lowlands Express' AND c.name IN ('Netherlands', 'Belgium', 'France') THEN 'Lowlands core (NL/BE/FR)' WHEN ews.carrier = 'Lowlands Express' THEN 'Lowlands non-core (other countries)' ELSE 'All other carriers combined' END AS lane_group FROM eligible_with_shipment ews LEFT JOIN addresses a ON a.id = ews.shipping_address_id LEFT JOIN countries c ON c.id = a.country_id ), lane_groups AS ( SELECT 'Lowlands core (NL/BE/FR)' AS lane_group, 1 AS sort_order UNION ALL SELECT 'Lowlands non-core (other countries)', 2 UNION ALL SELECT 'All other carriers combined', 3 ), lane_stats AS ( SELECT lane_group, COUNT(*) AS orders_fully_delivered, AVG(delivery_days) AS avg_delivery_days, AVG(CASE WHEN delivery_days <= 5 THEN 1.0 ELSE 0.0 END) * 100 AS pct_within_5_days FROM order_lane GROUP BY lane_group ), totals AS ( SELECT SUM(orders_fully_delivered) AS total_orders FROM lane_stats ) SELECT lg.lane_group AS lane_group, COALESCE(ls.orders_fully_delivered, 0) AS orders_fully_delivered, ls.avg_delivery_days AS avg_delivery_days, ls.pct_within_5_days AS pct_within_5_days, CAST(COALESCE(ls.orders_fully_delivered, 0) AS numeric(18,6)) / NULLIF(t.total_orders, 0) * 100 AS share_of_orders_pct FROM lane_groups lg LEFT JOIN lane_stats ls ON ls.lane_group = lg.lane_group CROSS JOIN totals t ORDER BY lg.sort_order NULLS LAST
WITH order_fulfillment_counts AS ( SELECT order_id, COUNT(*) AS fulfillment_count FROM fulfillments GROUP BY order_id ), fulfillment_shipment_counts AS ( SELECT fulfillment_id, COUNT(*) AS shipment_count FROM shipments GROUP BY fulfillment_id ), eligible_orders AS ( SELECT o.id AS order_id, o.placed_at AS placed_at, o.shipping_address_id AS shipping_address_id, f.id AS fulfillment_id FROM orders o JOIN order_fulfillment_counts ofc ON ofc.order_id = o.id AND ofc.fulfillment_count = 1 JOIN fulfillments f ON f.order_id = o.id WHERE o.status = 'fulfilled' AND o.placed_at >= DATE '2025-01-01' AND o.placed_at < DATE '2026-01-01' ), eligible_with_shipment AS ( SELECT eo.order_id AS order_id, eo.placed_at AS placed_at, eo.shipping_address_id AS shipping_address_id, s.carrier AS carrier, s.delivered_at AS delivered_at FROM eligible_orders eo JOIN fulfillment_shipment_counts fsc ON fsc.fulfillment_id = eo.fulfillment_id AND fsc.shipment_count = 1 JOIN shipments s ON s.fulfillment_id = eo.fulfillment_id WHERE s.delivered_at IS NOT NULL ), order_lane AS ( SELECT ews.order_id AS order_id, CAST(divideDecimal(toDecimal128(dateDiff('microsecond', ews.placed_at, ews.delivered_at), 0), toDecimal128(1000000, 0), 6) AS Nullable(Decimal(18, 6))) / 86400.0 AS delivery_days, CASE WHEN ews.carrier = 'Lowlands Express' AND c.name IN ('Netherlands', 'Belgium', 'France') THEN 'Lowlands core (NL/BE/FR)' WHEN ews.carrier = 'Lowlands Express' THEN 'Lowlands non-core (other countries)' ELSE 'All other carriers combined' END AS lane_group FROM eligible_with_shipment ews LEFT JOIN addresses a ON a.id = ews.shipping_address_id LEFT JOIN countries c ON c.id = a.country_id ), lane_groups AS ( SELECT 'Lowlands core (NL/BE/FR)' AS lane_group, 1 AS sort_order UNION ALL SELECT 'Lowlands non-core (other countries)', 2 UNION ALL SELECT 'All other carriers combined', 3 ), lane_stats AS ( SELECT lane_group, COUNT(*) AS orders_fully_delivered, AVG(delivery_days) AS avg_delivery_days, AVG(CASE WHEN delivery_days <= 5 THEN 1.0 ELSE 0.0 END) * 100 AS pct_within_5_days FROM order_lane GROUP BY lane_group ), totals AS ( SELECT SUM(orders_fully_delivered) AS total_orders FROM lane_stats ) SELECT lg.lane_group AS lane_group, COALESCE(ls.orders_fully_delivered, 0) AS orders_fully_delivered, ls.avg_delivery_days AS avg_delivery_days, ls.pct_within_5_days AS pct_within_5_days, CAST(COALESCE(ls.orders_fully_delivered, 0) AS numeric(18,6)) / NULLIF(t.total_orders, 0) * 100 AS share_of_orders_pct FROM lane_groups lg LEFT JOIN lane_stats ls ON ls.lane_group = lg.lane_group CROSS JOIN totals t ORDER BY lg.sort_order NULLS LAST
The agents' own records, as the role play wrote them; only the personal data of the person who ran it is redacted
Report request from Lena Hartmann (analyst for the Chief Operating Officer):
Title: Order-level delivery reliability: Lowlands Express by destination lane, full year 2025 (unified re-check)
Question: Confirmed and reconciled: how much does Lowlands Express's order-level reliability differ between its home lanes (Netherlands/Belgium/France) and everywhere else, versus the rest of our carriers combined?
Grain: one row per lane_group: 'Lowlands core (NL/BE/FR)', 'Lowlands non-core (other countries)', 'All other carriers combined'
Columns:
- lane_group
- orders_fully_delivered
- avg_delivery_days
- pct_within_5_days
- share_of_orders_pct
Details: Same scoping and single-carrier attribution rule as the other two reports in this set (orders placed_at in 2025, status='fulfilled', exactly one fulfillment with exactly one shipment, delivered_at not null). For orders where shipments.carrier = 'Lowlands Express', split by destination country (orders.shipping_address_id -> addresses -> countries.name): 'Lowlands core (NL/BE/FR)' if country in ('Netherlands','Belgium','France'), else 'Lowlands non-core (other countries)'. All remaining orders (any other carrier) go to 'All other carriers combined'. Please also report the raw count of orders in each group and confirm the three groups sum to the same total order count as the full-year carrier report in this batch, so I can verify consistency across the two reports. Round avg_delivery_days to 2 decimals, pct columns to 1 decimal. Order: Lowlands core first, then Lowlands non-core, then All other carriers combined. Expect 3 rows.
Check your query with the warehouse's dry_run tool, then hand it in with submit.dry_runWITH order_fulfillment_counts AS ( SELECT order_id, COUNT(*) AS fulfillment_count FROM fulfillments GROUP BY order_id ), fulfillment_shipment_counts AS ( SELECT fulfillment_id, COUNT(*) AS shipment_count FROM shipments GROUP BY fulfillment_id ), eligible_orders AS ( SELECT o.id AS order_id, o.placed_at, o.shipping_address_id, f.id AS fulfillment_id FROM orders o JOIN order_fulfillment_counts ofc ON ofc.order_id = o.id AND ofc.fulfillment_count = 1 JOIN fulfillments f ON f.order_id = o.id WHERE o.status = 'fulfilled' AND o.placed_at >= DATE '2025-01-01' AND o.placed_at < DATE '2026-01-01' ), eligible_with_shipment AS ( SELECT eo.order_id, eo.placed_at, eo.shipping_address_id, s.carrier, s.delivered_at FROM eligible_orders eo JOIN fulfillment_shipment_counts fsc ON fsc.fulfillment_id = eo.fulfillment_id AND fsc.shipment_count = 1 JOIN shipments s ON s.fulfillment_id = eo.fulfillment_id WHERE s.delivered_at IS NOT NULL ), order_lane AS ( SELECT ews.order_id, EXTRACT(EPOCH FROM (ews.delivered_at - ews.placed_at)) / 86400.0 AS delivery_days, CASE WHEN ews.carrier = 'Lowlands Express' AND c.name IN ('Netherlands', 'Belgium', 'France') THEN 'Lowlands core (NL/BE/FR)' WHEN ews.carrier = 'Lowlands Express' THEN 'Lowlands non-core (other countries)' ELSE 'All other carriers combined' END AS lane_group FROM eligible_with_shipment ews LEFT JOIN addresses a ON a.id = ews.shipping_address_id LEFT JOIN countries c ON c.id = a.country_id ), lane_groups AS ( SELECT 'Lowlands core (NL/BE/FR)' AS lane_group, 1 AS sort_order UNION ALL SELECT 'Lowlands non-core (other countries)', 2 UNION ALL SELECT 'All other carriers combined', 3 ), lane_stats AS ( SELECT lane_group, COUNT(*) AS orders_fully_delivered, AVG(delivery_days) AS avg_delivery_days, AVG(CASE WHEN delivery_days <= 5 THEN 1.0 ELSE 0.0 END) * 100 AS pct_within_5_days FROM order_lane GROUP BY lane_group ), totals AS ( SELECT SUM(orders_fully_delivered) AS total_orders FROM lane_stats ) SELECT lg.lane_group, COALESCE(ls.orders_fully_delivered, 0) AS orders_fully_delivered, ROUND(CAST(ls.avg_delivery_days AS numeric), 2) AS avg_delivery_days, ROUND(CAST(ls.pct_within_5_days AS numeric), 1) AS pct_within_5_days, ROUND(CAST(COALESCE(ls.orders_fully_delivered, 0) AS numeric) / NULLIF(t.total_orders, 0) * 100, 1) AS share_of_orders_pct FROM lane_groups lg LEFT JOIN lane_stats ls ON ls.lane_group = lg.lane_group CROSS JOIN totals t ORDER BY lg.sort_order
STATUS: COMPILES (dry run on the empty schema, no data read) COLUMNS: lane_group, orders_fully_delivered, avg_delivery_days, pct_within_5_days, share_of_orders_pct
submitWITH order_fulfillment_counts AS ( SELECT order_id, COUNT(*) AS fulfillment_count FROM fulfillments GROUP BY order_id ), fulfillment_shipment_counts AS ( SELECT fulfillment_id, COUNT(*) AS shipment_count FROM shipments GROUP BY fulfillment_id ), eligible_orders AS ( SELECT o.id AS order_id, o.placed_at, o.shipping_address_id, f.id AS fulfillment_id FROM orders o JOIN order_fulfillment_counts ofc ON ofc.order_id = o.id AND ofc.fulfillment_count = 1 JOIN fulfillments f ON f.order_id = o.id WHERE o.status = 'fulfilled' AND o.placed_at >= DATE '2025-01-01' AND o.placed_at < DATE '2026-01-01' ), eligible_with_shipment AS ( SELECT eo.order_id, eo.placed_at, eo.shipping_address_id, s.carrier, s.delivered_at FROM eligible_orders eo JOIN fulfillment_shipment_counts fsc ON fsc.fulfillment_id = eo.fulfillment_id AND fsc.shipment_count = 1 JOIN shipments s ON s.fulfillment_id = eo.fulfillment_id WHERE s.delivered_at IS NOT NULL ), order_lane AS ( SELECT ews.order_id, EXTRACT(EPOCH FROM (ews.delivered_at - ews.placed_at)) / 86400.0 AS delivery_days, CASE WHEN ews.carrier = 'Lowlands Express' AND c.name IN ('Netherlands', 'Belgium', 'France') THEN 'Lowlands core (NL/BE/FR)' WHEN ews.carrier = 'Lowlands Express' THEN 'Lowlands non-core (other countries)' ELSE 'All other carriers combined' END AS lane_group FROM eligible_with_shipment ews LEFT JOIN addresses a ON a.id = ews.shipping_address_id LEFT JOIN countries c ON c.id = a.country_id ), lane_groups AS ( SELECT 'Lowlands core (NL/BE/FR)' AS lane_group, 1 AS sort_order UNION ALL SELECT 'Lowlands non-core (other countries)', 2 UNION ALL SELECT 'All other carriers combined', 3 ), lane_stats AS ( SELECT lane_group, COUNT(*) AS orders_fully_delivered, AVG(delivery_days) AS avg_delivery_days, AVG(CASE WHEN delivery_days <= 5 THEN 1.0 ELSE 0.0 END) * 100 AS pct_within_5_days FROM order_lane GROUP BY lane_group ), totals AS ( SELECT SUM(orders_fully_delivered) AS total_orders FROM lane_stats ) SELECT lg.lane_group, COALESCE(ls.orders_fully_delivered, 0) AS orders_fully_delivered, ROUND(CAST(ls.avg_delivery_days AS numeric), 2) AS avg_delivery_days, ROUND(CAST(ls.pct_within_5_days AS numeric), 1) AS pct_within_5_days, ROUND(CAST(COALESCE(ls.orders_fully_delivered, 0) AS numeric) / NULLIF(t.total_orders, 0) * 100, 1) AS share_of_orders_pct FROM lane_groups lg LEFT JOIN lane_stats ls ON ls.lane_group = lg.lane_group CROSS JOIN totals t ORDER BY lg.sort_order
Submitted to tonight's batch. Your work on this request is done.