DB Olympics

Queries · q404 · Support Operations Manager · week 2, night 3

Carrier mix and on-time delivery performance, flagged merchants vs. Cragsley

“Do Marrowby & Vane and Studio Vrij rely on a slower or less reliable carrier than Cragsley Outfitters, which would explain their outsized delivery/where-is-my-order ticket resolution times?”

Manager · asked the questionMia SchultzSupport Operations Manager. Built support tooling and processes at a software company.
Analyst · planned the reportBen CarterQuantifier: puts a money value on every finding.
Engineer · wrote the SQLOmarPragmatic: the shortest correct query, aggregates first and joins dimensions afterwards, FILTER clauses for conditional counts.

Fictional people at a fictional company, each played by a language-model agent. Who they are and what they are told

  1. A business event lands on the Support Operations Manager's desk

    Week 1; shared with Daniel Achterberg, VP Customer Experience

    Review how the helpdesk runs: queues and agent groups, use of macros and knowledge articles, SLA targets and breaches, and what makes tickets slow.

  2. Mia Schultz writes to Ben Carter

    The manager, at the start of week 2

    Subject: Re: Helpdesk Operating Review — great start, here's where to push next

    Ben,

    This is exactly the kind of baseline I wanted — and the speed-to-CSAT finding alone is worth putting in front of Daniel as-is. A few things stood out that I want sharpened before we present or act on them.

    What surprised me / needs explaining:

    • Marrowby & Vane and Studio Vrij are clearly our weak spot, but "under-resourced vs. harder cases" are two very different fixes (hire vs. retrain/reprioritize), and right now we can't tell which it is.
    • The macro usage number not reconciling with actual reply volume bothers me — I'd rather have no macro story this week than a wrong one, so let's not repeat that figure anywhere until it's explained.
    • The topic/tag breakdown (damaged, account, product-question) is useful but I don't want to act on it until we know how much of our ticket volume isn't tagged at all.

    Questions for next week, in priority order:

    1. For Marrowby & Vane and Studio Vrij specifically: is their breach rate because they're thinner on agents relative to their ticket load, or because their tickets take genuinely longer regardless of staffing (harder issues, bigger customers, more back-and-forth)? I want enough to recommend either "add headcount" or "something else is going on" with confidence.
    2. Before we use the macro usage figures for anything: what is that count actually tracking, and can we get a trustworthy sense of how much agents lean on canned replies versus writing from scratch?
    3. What share of tickets carry no topic tag at all, and does that change the story on which topics breach most? I don't want to walk into a training conversation with a skewed sample.
    4. If there's room: can we get even a rough signal on whether people who view a knowledge article before contacting us end up not filing a ticket at all, or filing a faster one? Even a partial read would tell us if KB investment is worth pushing on next quarter.

    Thanks — this is shaping up well. Let's make next week about turning the Marrowby & Vane / Studio Vrij question into something actionable.

    Mia

  3. Ben Carter plans the night

    The analyst · week 2, night 3, request 1 of 3

    Big lead from last night: Report 1 shows Studio Vrij's delivery-tagged tickets average 10,482 minutes and where-is-my-order tickets 10,801 minutes — roughly 6x Cragsley's 1,697/1,819 minutes for the exact same tags — and these two tags are 57-59% of Studio Vrij's entire ticket volume. Marrowby & Vane shows the same pattern at ~4x Cragsley's pace. That's a huge, tag-specific, isolated gap that looks like a fulfillment/carrier problem bleeding into support, not an agent-skill or staffing problem — and it lines up with what the COO and VP CX teams posted this week (a carrier breakdown, and delivery delays driving 'where's my order' tickets). I want to chase that directly tonight by looking at these two tenants' actual shipment/carrier performance. Report 2 (first-response vs post-response split) turned out less diagnostic than hoped: the 50/50 split between first-response delay and post-response delay is nearly identical across all three tenants, so it doesn't distinguish 'slow to start' from 'slow to finish' — both phases just run slower end-to-end for the flagged merchants, consistent with an external (carrier) cause rather than an internal process-stage cause. Report 3 (KB engagement) came back all zeros — the guessed path patterns don't exist in this data, which tells us nothing except that we need to find the real signal before trying again, so I'm spending one slot on that reconnaissance rather than guessing blind a second time.

    Carrier mix and on-time delivery performance, flagged merchants vs. Cragsley
    Question
    Do Marrowby & Vane and Studio Vrij rely on a slower or less reliable carrier than Cragsley Outfitters, which would explain their outsized delivery/where-is-my-order ticket resolution times?
    One row per
    (tenant, carrier), restricted to Marrowby & Vane, Studio Vrij, and Cragsley Outfitters
    Columns
    • tenant_name
    • carrier
    • shipment_count (shipped_at in 2025)
    • pct_of_tenant_shipments
    • avg_delivery_days (delivered_at - shipped_at, for shipments with both timestamps)
    • pct_delivered_within_3_days
  4. Omar writes the SQL

    The engineer · 1 dry run on the empty schema, then the submission

    Dry run 1 · STATUS: COMPILES (dry run on the empty schema, no data read)
    SELECT
      t.name AS tenant_name,
      s.carrier,
      count(*) AS shipment_count,
      round(100.0 * count(*) / sum(count(*)) over (partition by t.name), 1) AS pct_of_tenant_shipments,
      round(avg(extract(epoch from (s.delivered_at - s.shipped_at)) / 86400.0) filter (where s.delivered_at is not null and s.shipped_at is not null), 1) AS avg_delivery_days,
      round(100.0 * count(*) filter (where s.delivered_at is not null and s.shipped_at is not null and s.delivered_at - s.shipped_at <= interval '3 days')
            / nullif(count(*) filter (where s.delivered_at is not null and s.shipped_at is not null), 0), 1) AS pct_delivered_within_3_days
    FROM shipments s
    JOIN tenants t ON t.id = s.tenant_id
    WHERE t.name IN ('Marrowby & Vane', 'Studio Vrij', 'Cragsley Outfitters')
      AND s.shipped_at >= timestamp '2025-01-01'
      AND s.shipped_at < timestamp '2026-01-01'
    GROUP BY t.name, s.carrier
    ORDER BY t.name, shipment_count DESC

    “Query compiles and matches the requested grain and columns.”

    Submitted · the SQL of the last dry run, unchanged · Submitted to tonight's batch. Your work on this request is done.

    “Submitted. The report gives one row per (tenant, carrier) for Marrowby & Vane, Studio Vrij, and Cragsley Outfitters, covering 2025 shipments, with shipment counts, each carrier's share of that tenant's volume, average delivery days, and the share delivered within 3 days — ordered by tenant then by shipment volume so the dominant carrier per merchant is easy to spot and compare.”

  5. The report comes back overnight

    As Ben Carter saw it, from the small dataset the agents worked on

    tenant_name         | carrier              | shipment_count | pct_of_tenant_shipments | avg_delivery_days | pct_delivered_within_3_days
    --------------------+----------------------+----------------+-------------------------+-------------------+----------------------------
    Cragsley Outfitters | Liberty Ground       |           1634 |                    46.9 |               2.3 |                        80.3
    Cragsley Outfitters | Trailhead Express    |           1253 |                    36.0 |               2.5 |                        73.1
    Cragsley Outfitters | Prairie Line Express |            511 |                    14.7 |               2.6 |                        70.4
    Cragsley Outfitters | Landfall Freight     |             85 |                     2.4 |               4.3 |                        24.1
    Marrowby & Vane     | Albion Parcel        |            863 |                    51.6 |               2.5 |                        76.8
    Marrowby & Vane     | Regent Parcels       |            260 |                    15.6 |               2.3 |                        76.7
    Marrowby & Vane     | Kennet Freight       |            219 |                    13.1 |               1.9 |                        90.1
    Marrowby & Vane     | Landfall Freight     |            192 |                    11.5 |               6.4 |                         9.0
    Marrowby & Vane     | Lowlands Express     |            137 |                     8.2 |               6.1 |                         9.9
    Studio Vrij         | Lowlands Express     |            347 |                    58.1 |               2.5 |                        71.0
    Studio Vrij         | Polder Post          |            188 |                    31.5 |               2.7 |                        63.2
    Studio Vrij         | Landfall Freight     |             62 |                    10.4 |               4.3 |                        18.3
    (12 rows)
  6. What came of it

    The memo and the queries that followed; links found by title, so inferred

    Later queries that build on this report:

    It builds on:

  7. It becomes benchmark query q404

    Changed only where the benchmark needs the same result on every system

    • determinismtie-breaker: the rest of the group key
    • numericsdocs/NUMERICS.md: rounding removed; results keep full precision
    • numericsdocs/NUMERICS.md: EXTRACT(EPOCH FROM (b - a)) cast to NUMERIC(18,6)
    • made explicita selected t.col gets AS col, its standard name made explicit
    • placeholderseconds between
    • determinismthe standard leaves the place of NULLs in a sort to the implementation: NULLS LAST ascending, NULLS FIRST descending, as in the reference results (3×)
    The benchmark text, against the submitted SQL
    SELECT  t.name AS tenant_name,  s.carrier,  s.carrier AS carrier,  count(*) AS shipment_count,  round(100.0 * count(*) / sum(count(*)) over (partition by t.name), 1) AS pct_of_tenant_shipments,  round(avg(extract(epoch from (s.delivered_at - s.shipped_at)) / 86400.0) filter (where s.delivered_at is not null and s.shipped_at is not null), 1) AS avg_delivery_days,  round(100.0 * count(*) filter (where s.delivered_at is not null and s.shipped_at is not null and s.delivered_at - s.shipped_at <= interval '3 days')        / nullif(count(*) filter (where s.delivered_at is not null and s.shipped_at is not null), 0), 1) AS pct_delivered_within_3_days  100.0 * count(*) / sum(count(*)) over (partition by t.name) AS pct_of_tenant_shipments,  avg({{seconds_between(s.shipped_at, s.delivered_at)}} / 86400.0) filter (where s.delivered_at is not null and s.shipped_at is not null) AS avg_delivery_days,  100.0 * count(*) filter (where s.delivered_at is not null and s.shipped_at is not null and s.delivered_at - s.shipped_at <= interval '3 days')  / nullif(count(*) filter (where s.delivered_at is not null and s.shipped_at is not null), 0) AS pct_delivered_within_3_daysFROM shipments sJOIN tenants t ON t.id = s.tenant_idWHERE t.name IN ('Marrowby & Vane', 'Studio Vrij', 'Cragsley Outfitters')  AND s.shipped_at >= timestamp '2025-01-01'  AND s.shipped_at < timestamp '2026-01-01'GROUP BY t.name, s.carrierORDER BY t.name, shipment_count DESCORDER BY t.name NULLS LAST, shipment_count DESC NULLS FIRST, s.carrier NULLS LAST
    SELECT
      t.name AS tenant_name,
      s.carrier AS carrier,
      count(*) AS shipment_count,
      100.0 * count(*) / sum(count(*)) over (partition by t.name) AS pct_of_tenant_shipments,
      avg(CAST(EXTRACT(EPOCH FROM (s.delivered_at - s.shipped_at)) AS NUMERIC(18,6)) / 86400.0) filter (where s.delivered_at is not null and s.shipped_at is not null) AS avg_delivery_days,
      100.0 * count(*) filter (where s.delivered_at is not null and s.shipped_at is not null and s.delivered_at - s.shipped_at <= interval '3 days')
      / nullif(count(*) filter (where s.delivered_at is not null and s.shipped_at is not null), 0) AS pct_delivered_within_3_days
    FROM shipments s
    JOIN tenants t ON t.id = s.tenant_id
    WHERE t.name IN ('Marrowby & Vane', 'Studio Vrij', 'Cragsley Outfitters')
      AND s.shipped_at >= timestamp '2025-01-01'
      AND s.shipped_at < timestamp '2026-01-01'
    GROUP BY t.name, s.carrier
    ORDER BY t.name NULLS LAST, shipment_count DESC NULLS FIRST, s.carrier NULLS LAST
    10 ms100 msHyper25.9 msDuckDB58.5 msGizmoSQL66.8 msclickhouse_brew94.8 msFirebolt95.4 msDataFusionwrong resultClickHouseerror
    • DataFusionrow 1: col 6: "83.4504845713435489782017594943115537931207" vs "100.0"
    • ClickHouseCode: 43. DB::Exception: No operation lessOrEquals between Decimal(18, 6) and IntervalDay: while executing 'FUNCTION lessOrEquals(minus(__table1.delivered_at, __table1.shipped_at) :: 12, _CAST(3_IntervalDay, 'IntervalDay'_String) :: 10) -> lessOrEquals(minus(__table1.delivered_at, __table1.shipped_a
  8. Everything, as recorded

    The agents' own records, as the role play wrote them; only the personal data of the person who ran it is redacted

    Omar's whole session, 7 turns
    • The request, as Omar received it
      Report request from Ben Carter (analyst for the Support Operations Manager):
      
      Title: Carrier mix and on-time delivery performance, flagged merchants vs. Cragsley
      Question: Do Marrowby & Vane and Studio Vrij rely on a slower or less reliable carrier than Cragsley Outfitters, which would explain their outsized delivery/where-is-my-order ticket resolution times?
      Grain: one row per (tenant, carrier), restricted to Marrowby & Vane, Studio Vrij, and Cragsley Outfitters
      Columns:
      - tenant_name
      - carrier
      - shipment_count (shipped_at in 2025)
      - pct_of_tenant_shipments
      - avg_delivery_days (delivered_at - shipped_at, for shipments with both timestamps)
      - pct_delivered_within_3_days
      Details: Window: shipments.shipped_at between 2025-01-01 and 2025-12-31, restricted to tenant_id for the three named tenants (shipments has tenant_id directly). Source table: shipments. Order by tenant_name, then shipment_count descending within tenant. Round pct columns to 1 decimal percent, avg_delivery_days to 1 decimal. Goal: see if Studio Vrij/Marrowby & Vane are concentrated on a carrier with materially worse on-time performance than whatever Cragsley mostly uses.
      
      Check your query with the warehouse's dry_run tool, then hand it in with submit.
    • Omar calls dry_run
      SELECT
        t.name AS tenant_name,
        s.carrier,
        count(*) AS shipment_count,
        round(100.0 * count(*) / sum(count(*)) over (partition by t.name), 1) AS pct_of_tenant_shipments,
        round(avg(extract(epoch from (s.delivered_at - s.shipped_at)) / 86400.0) filter (where s.delivered_at is not null and s.shipped_at is not null), 1) AS avg_delivery_days,
        round(100.0 * count(*) filter (where s.delivered_at is not null and s.shipped_at is not null and s.delivered_at - s.shipped_at <= interval '3 days')
              / nullif(count(*) filter (where s.delivered_at is not null and s.shipped_at is not null), 0), 1) AS pct_delivered_within_3_days
      FROM shipments s
      JOIN tenants t ON t.id = s.tenant_id
      WHERE t.name IN ('Marrowby & Vane', 'Studio Vrij', 'Cragsley Outfitters')
        AND s.shipped_at >= timestamp '2025-01-01'
        AND s.shipped_at < timestamp '2026-01-01'
      GROUP BY t.name, s.carrier
      ORDER BY t.name, shipment_count DESC
    • The warehouse answers
      STATUS: COMPILES (dry run on the empty schema, no data read)
      COLUMNS: tenant_name, carrier, shipment_count, pct_of_tenant_shipments, avg_delivery_days, pct_delivered_within_3_days
    • OmarQuery compiles and matches the requested grain and columns.
    • Omar calls submit
      SELECT
        t.name AS tenant_name,
        s.carrier,
        count(*) AS shipment_count,
        round(100.0 * count(*) / sum(count(*)) over (partition by t.name), 1) AS pct_of_tenant_shipments,
        round(avg(extract(epoch from (s.delivered_at - s.shipped_at)) / 86400.0) filter (where s.delivered_at is not null and s.shipped_at is not null), 1) AS avg_delivery_days,
        round(100.0 * count(*) filter (where s.delivered_at is not null and s.shipped_at is not null and s.delivered_at - s.shipped_at <= interval '3 days')
              / nullif(count(*) filter (where s.delivered_at is not null and s.shipped_at is not null), 0), 1) AS pct_delivered_within_3_days
      FROM shipments s
      JOIN tenants t ON t.id = s.tenant_id
      WHERE t.name IN ('Marrowby & Vane', 'Studio Vrij', 'Cragsley Outfitters')
        AND s.shipped_at >= timestamp '2025-01-01'
        AND s.shipped_at < timestamp '2026-01-01'
      GROUP BY t.name, s.carrier
      ORDER BY t.name, shipment_count DESC
    • The warehouse answers
      Submitted to tonight's batch. Your work on this request is done.
    • OmarSubmitted. The report gives one row per (tenant, carrier) for Marrowby & Vane, Studio Vrij, and Cragsley Outfitters, covering 2025 shipments, with shipment counts, each carrier's share of that tenant's volume, average delivery days, and the share delivered within 3 days — ordered by tenant then by shipment volume so the dominant carrier per merchant is easy to spot and compare.