DB Olympics

Queries · q061 · Head of Merchant Success · week 1, night 2

Test

“Test question”

Manager · asked the questionSamuel WhitcombeHead of Merchant Success. New in the role, owns the relationship with the largest merchants and quarterly business reviews with them in January.
Analyst · planned the reportArjun PatelSegmenter: breaks totals down by merchant size, vertical, country and channel.
Engineer · wrote the SQLGraceWrites tidy, layered CTEs with descriptive names, one step per CTE, then a final select.

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

  1. Samuel Whitcombe writes to Arjun Patel

    The manager, at the start of week 1

    Subject: What I need for merchant QBRs this month

    Hi Arjun,

    I'm diving into merchant health this week ahead of January's quarterly business reviews with our biggest accounts. I know you've only got a handful of report slots a night, so here's what matters most to me, roughly in priority order:

    1. Who are our biggest and most important merchants, and how are they actually doing? I want a sense of the size of each merchant's business with us (sales volume, order activity) and whether it's growing, flat, or shrinking lately. This is the backbone for every QBR conversation.
    2. Which merchants look like they're at risk right now? I'm thinking about warning signs like slowing sales, rising refunds or cancellations, unpaid invoices, or a drop-off in shopper activity. I want a shortlist I can proactively reach out to before they churn.
    3. Which merchants are thriving, and is there a pattern? I'd like to know who's growing fastest and whether there's anything they have in common (plan tier, vertical, region) that we could point to as a playbook for others.
    4. How healthy is each merchant's own customer base? For our top merchants, I want to understand whether their shoppers are coming back and buying again, or whether they're mostly one-and-done. This tells me how defensible their business is, which matters for how I advise them.
    5. Are merchants getting good support from us, and does it affect how they feel about us? I'd like a read on ticket volume and resolution experience for our top merchants, since I'll likely get asked about this directly in reviews.

    For context: these go straight into prep notes for one-on-one merchant reviews, so I care most about being able to point to specific merchants by name and tell a clear story about each one's trajectory. Broad trends across all 120 merchants are useful background, but the top merchants are what I'll be sitting across the table from this month.

    Let me know if you want me to rank these differently given the slot constraints — happy to cut the list if needed.

    Thanks, Samuel

  2. Arjun Patel plans the night

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

    test

    Test
    Question
    Test question
    One row per
    tenant
    Columns
    • a
    • b
  3. Grace 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.id as tenant_id,
        t.name as a,
        count(o.id) as b
    from tenants t
    left join orders o on o.tenant_id = t.id
    group by t.id, t.name
    order by t.id
    Submitted · the SQL of the last dry run, unchanged · Submitted to tonight's batch. Your work on this request is done.

    “Submitted. Note: since the request only contained placeholder content ("Test"/"a"/"b") with no real business question, I delivered a minimal one-row-per-tenant report (tenant name, lifetime order count) and flagged in the note that Arjun should resend the actual question and metric definitions for a meaningful report.”

  4. The report comes back overnight

    As Arjun Patel saw it, from the small dataset the agents worked on

    tenant_id | a                             |    b
    ----------+-------------------------------+-----
            1 | Grind Collective              | 2269
            2 | Marrowby & Vane               | 4064
            3 | Juniper Apothecary            |  405
            4 | Hus & Hem                     |  167
            5 | Fennel & Flint                |  824
            6 | Willow & Wren                 |  317
            7 | Cragsley Outfitters           | 8965
            8 | Castell Fasteners             |  394
            9 | Honeycomb Larder              | 1450
           10 | Wohnglück                     |  330
           11 | Ballycorran Industrial Supply |  853
           12 | Spice Route Box               | 1872
           13 | Rue Lafayette Studio          |  410
           14 | OfficeHub Nordic              |  443
           15 | Velo Noord                    |   98
           16 | Ostwind Mode                  |  284
           17 | Ampfeld Elektronik            | 1058
           18 | Brennquell Kaffee             | 9996
           19 | Kontor24 Bürobedarf           |  637
           20 | Sourdough Club                |  843
           21 | Kettle & Key                  |  128
           22 | Midland Safety Wear           |  367
           23 | Mirelle                       |  102
           24 | Fern & Fable                  |  116
           25 | Studio Vrij                   | 1451
           26 | Velvet Ash                    |  355
           27 | Ampere & Co.                  |  159
           28 | Atelier Nouveau               |  196
           29 | Cinder Peak Sports Co.        |  759
           30 | Linden & Loom                 |  686
           31 | Hound Hamper                  |  120
           32 | Oakhurst Tailoring            |  317
           33 | Fell & Fjell                  |  201
           34 | Paperplane Press              |  135
           35 | Wiesgrund Wohnen              |  763
           36 | Fjordline Wear                |  141
           37 | Pfotenglück                   |  341
           38 | Coastline Interiors           |  350
           39 | Kayak Corner                  |  333
           40 | Petalcourt Beauty             | 1540
           41 | The Balm Room                 |  219
           42 | Gratlinie Outdoor             |  577
           43 | Roast Republic                |  109
           44 | Whisker Works                 |  401
           45 | Maison Clair                  |  100
           46 | Feather & Fin                 |  411
           47 | Tail Wag Supply               |  221
           48 | Ridgeback Gear                |  247
           49 | Stoneware Studio              |   54
           50 | Buchstabe                     |   64
    (120 rows, first 50 printed)
  5. It becomes benchmark query q061

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

    • determinismthe standard leaves the place of NULLs in a sort to the implementation: NULLS LAST ascending, NULLS FIRST descending, as in the reference results
    The benchmark text, against the submitted SQL
    select    t.id as tenant_id,    t.name as a,    count(o.id) as bfrom tenants tleft join orders o on o.tenant_id = t.idgroup by t.id, t.nameorder by t.idorder by t.id NULLS LAST
    select
        t.id as tenant_id,
        t.name as a,
        count(o.id) as b
    from tenants t
    left join orders o on o.tenant_id = t.id
    group by t.id, t.name
    order by t.id NULLS LAST
    10 ms100 ms1 sHyper10.3 msDuckDB32.7 msGizmoSQL34.7 msclickhouse_brew176 msFirebolt91.6 msDataFusion100 msClickHouse165 ms
  6. 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

    Grace's whole session, 6 turns
    • The request, as Grace received it
      Report request from Arjun Patel (analyst for the Head of Merchant Success):
      
      Title: Test
      Question: Test question
      Grain: one row per tenant
      Columns:
      - a
      - b
      Details: test details
      
      Check your query with the warehouse's dry_run tool, then hand it in with submit.
    • Grace calls dry_run
      select
          t.id as tenant_id,
          t.name as a,
          count(o.id) as b
      from tenants t
      left join orders o on o.tenant_id = t.id
      group by t.id, t.name
      order by t.id
    • The warehouse answers
      STATUS: COMPILES (dry run on the empty schema, no data read)
      COLUMNS: tenant_id, a, b
    • Grace calls submit
      select
          t.id as tenant_id,
          t.name as a,
          count(o.id) as b
      from tenants t
      left join orders o on o.tenant_id = t.id
      group by t.id, t.name
      order by t.id
    • The warehouse answers
      Submitted to tonight's batch. Your work on this request is done.
    • GraceSubmitted. Note: since the request only contained placeholder content ("Test"/"a"/"b") with no real business question, I delivered a minimal one-row-per-tenant report (tenant name, lifetime order count) and flagged in the note that Arjun should resend the actual question and metric definitions for a meaningful report.