Queries · q096 · Head of Data · week 1, night 3
“Do different reasonable definitions of 'how many customers we have' or 'how many are active' give meaningfully different headcounts?”
Fictional people at a fictional company, each played by a language-model agent. Who they are and what they are told
Week 1; shared with Tobias Lindqvist, Chief Financial Officer
Before the board pack goes out, Data must certify the key metrics. Do revenue, orders, customers, refunds and payouts agree wherever they are recorded, and where they do not, why not and by how much?
The manager, at the start of week 1
Subject: Certifying the key metrics before the board pack — what I need from you this week
Hi Yuki,
Tobias and I have to certify revenue, orders, customers, refunds and payouts before they go into the board pack. "Certify" means we're telling the board these numbers are reconcilable — so this week's job is to find out where the different places we record these figures agree, where they don't, and whether any gap is big enough to change the story we tell. If something doesn't reconcile, I need to know why and by how much, not just that it's "close enough." That feeds directly into the go/no-go Tobias and I give on the board pack, so please prioritize breadth across the five metrics over depth on any one of them — we can always dig deeper next week on whichever one looks shakiest.
You only have a handful of report slots a night, so here's what matters most to me, roughly in priority order:
Please flag anything you find inconsistent together with your best read of why, and roughly how big the discrepancy is in practice — that's what Tobias and I need to decide whether we can certify as-is, certify with a caveat, or need to hold a number back.
Thank you — I know this is a lot for one week. Let's talk before you spend your first slot tonight if you want to sanity-check the plan.
Rosa
Subject: What I need for the revenue/payout certification
Hi Yuki,
A few things from my side as you scope this week's work:
If anything else jumps out while you're in there — especially around currency conversion timing or refund treatment — flag it even if it's outside these three.
Thanks, Tobias
The analyst · week 1, night 3, request 3 of 3
Night 2 gave three follow-ups worth running tonight. (1) The order-status breakdown showed "refunded" orders at a near-total 99.8% gap and "fulfilled" orders at a persistent 22% gap — I suspect both are partly a filter artifact: my captured-payment match only counted payments.status='captured', but a payment that was later refunded moves to status 'refunded'/'partially_refunded' and would be invisible to that filter even though money genuinely changed hands. I want to re-run with a status-inclusive filter to see how much of the gap is this artifact vs a real reconciliation hole, especially for 'fulfilled' orders where there's no reason to expect any gap at all. (2) The payment-linked payout/refund check got noisier, not cleaner, than the calendar-month version (swinging -16.6% to +17.7% with no consistent sign) — payout_items has a unique constraint on payment_id (one row per payment, ever), so a refund processed after a payment's payout has already settled has no slot in that payout to be reflected in; it would have to hit some later, differently-linked settlement, breaking the clean per-payout linkage I assumed. I want to directly test how often refunds are processed after their payment's payout already settled, since that would explain the noise and is itself a traceability gap worth flagging to Tobias. (3) Rosa's customer-count question (#4) hasn't been touched yet and we're entering the back half of the week, so I'm using tonight's third slot to get a first cut at how many "customers" we have under different plausible definitions, to see if that's a quick certify or another can of worms for night 4.
The engineer · 1 dry run on the empty schema, then the submission
SELECT t.definition, t.user_count, round(t.user_count * 100.0 / tot.total_count, 1) as pct_of_all_customers FROM ( SELECT 'All customers (ever created)' as definition, (SELECT count(distinct u1.id) FROM users u1 WHERE u1.is_staff = false AND u1.created_at < timestamp '2026-01-01') as user_count UNION ALL SELECT 'Status = active', (SELECT count(distinct u2.id) FROM users u2 WHERE u2.is_staff = false AND u2.status = 'active') UNION ALL SELECT 'Placed at least one order, ever', (SELECT count(distinct u3.id) FROM users u3 WHERE u3.is_staff = false AND EXISTS (SELECT 1 FROM orders o3 WHERE o3.user_id = u3.id AND o3.placed_at < timestamp '2026-01-01')) UNION ALL SELECT 'Placed at least one order in trailing 12 months', (SELECT count(distinct u4.id) FROM users u4 WHERE u4.is_staff = false AND EXISTS (SELECT 1 FROM orders o4 WHERE o4.user_id = u4.id AND o4.placed_at >= timestamp '2025-01-01' AND o4.placed_at < timestamp '2026-01-01')) UNION ALL SELECT 'Has an active or trialing subscription', (SELECT count(distinct u5.id) FROM users u5 WHERE u5.is_staff = false AND EXISTS (SELECT 1 FROM subscriptions s5 WHERE s5.user_id = u5.id AND s5.status IN ('active','trialing'))) UNION ALL SELECT 'Logged in within last 90 days of data', (SELECT count(distinct u6.id) FROM users u6 WHERE u6.is_staff = false AND u6.last_login_at >= timestamp '2025-10-03' AND u6.last_login_at < timestamp '2026-01-01') ) t CROSS JOIN ( SELECT count(distinct u0.id) as total_count FROM users u0 WHERE u0.is_staff = false AND u0.created_at < timestamp '2026-01-01' ) tot ORDER BY t.user_count DESC, t.definition
“Query compiles and returns the expected columns. Submitting.”
“Submitted. The report builds six customer-headcount definitions (all ever created, status=active, ever ordered, ordered in trailing 12 months, active/trialing subscription, logged in within 90 days) as one row each, with user_count and pct_of_all_customers computed against the "all customers ever created" denominator, ordered by headcount descending.”
As Yuki Tanaka saw it, from the small dataset the agents worked on
definition | user_count | pct_of_all_customers -----------------------------------------+------------+--------------------- All customers (ever created) | 11258 | 100.0 Status = active | 11183 | 99.3 Placed at least one order, ever | 9640 | 85.6 Placed at least one order in trailing 12 | 6159 | 54.7 Logged in within last 90 days of data | 5396 | 47.9 Has an active or trialing subscription | 411 | 3.7 (6 rows)
The memo and the queries that followed; links found by title, so inferred
Yuki Tanaka's memo to Rosa Van den Berg at the end of the week:
4. "How many customers" has no single answer — pick two. (Customer headcount by definition) Range from 11,258 (all accounts) down to 411 (active/trialing subscription, 3.7% — expected, most merchants aren't subscription businesses). "Status=active" (99.3%) is not a usable activity signal. I'd certify two headline numbers: 9,640 ever-purchased and 6,159 trailing-12-month purchasers.
Later queries that build on this report:
Changed only where the benchmark needs the same result on every system
SELECT t.definition, t.user_count, round(t.user_count * 100.0 / tot.total_count, 1) as pct_of_all_customers t.definition AS definition, t.user_count AS user_count, t.user_count * 100.0 / tot.total_count as pct_of_all_customersFROM ( SELECT 'All customers (ever created)' as definition, (SELECT count(distinct u1.id) FROM users u1 WHERE u1.is_staff = false AND u1.created_at < timestamp '2026-01-01') as user_count UNION ALL SELECT 'Status = active', (SELECT count(distinct u2.id) FROM users u2 WHERE u2.is_staff = false AND u2.status = 'active') UNION ALL SELECT 'Placed at least one order, ever', (SELECT count(distinct u3.id) FROM users u3 WHERE u3.is_staff = false AND EXISTS (SELECT 1 FROM orders o3 WHERE o3.user_id = u3.id AND o3.placed_at < timestamp '2026-01-01')) UNION ALL SELECT 'Placed at least one order in trailing 12 months', (SELECT count(distinct u4.id) FROM users u4 WHERE u4.is_staff = false AND EXISTS (SELECT 1 FROM orders o4 WHERE o4.user_id = u4.id AND o4.placed_at >= timestamp '2025-01-01' AND o4.placed_at < timestamp '2026-01-01')) UNION ALL SELECT 'Has an active or trialing subscription', (SELECT count(distinct u5.id) FROM users u5 WHERE u5.is_staff = false AND EXISTS (SELECT 1 FROM subscriptions s5 WHERE s5.user_id = u5.id AND s5.status IN ('active','trialing'))) UNION ALL SELECT 'Logged in within last 90 days of data', (SELECT count(distinct u6.id) FROM users u6 WHERE u6.is_staff = false AND u6.last_login_at >= timestamp '2025-10-03' AND u6.last_login_at < timestamp '2026-01-01')) tCROSS JOIN ( SELECT count(distinct u0.id) as total_count FROM users u0 WHERE u0.is_staff = false AND u0.created_at < timestamp '2026-01-01') totORDER BY t.user_count DESC, t.definitionORDER BY t.user_count DESC NULLS FIRST, t.definition NULLS LAST
SELECT t.definition AS definition, t.user_count AS user_count, t.user_count * 100.0 / tot.total_count as pct_of_all_customers FROM ( SELECT 'All customers (ever created)' as definition, (SELECT count(distinct u1.id) FROM users u1 WHERE u1.is_staff = false AND u1.created_at < timestamp '2026-01-01') as user_count UNION ALL SELECT 'Status = active', (SELECT count(distinct u2.id) FROM users u2 WHERE u2.is_staff = false AND u2.status = 'active') UNION ALL SELECT 'Placed at least one order, ever', (SELECT count(distinct u3.id) FROM users u3 WHERE u3.is_staff = false AND EXISTS (SELECT 1 FROM orders o3 WHERE o3.user_id = u3.id AND o3.placed_at < timestamp '2026-01-01')) UNION ALL SELECT 'Placed at least one order in trailing 12 months', (SELECT count(distinct u4.id) FROM users u4 WHERE u4.is_staff = false AND EXISTS (SELECT 1 FROM orders o4 WHERE o4.user_id = u4.id AND o4.placed_at >= timestamp '2025-01-01' AND o4.placed_at < timestamp '2026-01-01')) UNION ALL SELECT 'Has an active or trialing subscription', (SELECT count(distinct u5.id) FROM users u5 WHERE u5.is_staff = false AND EXISTS (SELECT 1 FROM subscriptions s5 WHERE s5.user_id = u5.id AND s5.status IN ('active','trialing'))) UNION ALL SELECT 'Logged in within last 90 days of data', (SELECT count(distinct u6.id) FROM users u6 WHERE u6.is_staff = false AND u6.last_login_at >= timestamp '2025-10-03' AND u6.last_login_at < timestamp '2026-01-01') ) t CROSS JOIN ( SELECT count(distinct u0.id) as total_count FROM users u0 WHERE u0.is_staff = false AND u0.created_at < timestamp '2026-01-01' ) tot ORDER BY t.user_count DESC NULLS FIRST, t.definition 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 Yuki Tanaka (analyst for the Head of Data):
Title: Customer headcount by definition
Question: Do different reasonable definitions of 'how many customers we have' or 'how many are active' give meaningfully different headcounts?
Grain: customer count definition
Columns:
- definition
- user_count
- pct_of_all_customers
Details: Scope: all tenants combined, non-staff users only (users.is_staff = false). As-of date for all 'current state' columns: the data cutoff 2025-12-31. Rows (definitions), each counting distinct users.id: (1) 'All customers (ever created)' - all non-staff users with created_at <= 2025-12-31; this is the denominator for pct_of_all_customers. (2) 'Status = active' - users.status = 'active'. (3) 'Placed at least one order, ever' - distinct users.id appearing in orders (any status) with placed_at <= 2025-12-31. (4) 'Placed at least one order in trailing 12 months' - distinct users.id with an order placed_at between 2025-01-01 and 2025-12-31. (5) 'Has an active or trialing subscription' - distinct users.id with a subscriptions row where status in ('active','trialing'). (6) 'Logged in within last 90 days of data' - users.last_login_at >= 2025-10-03. pct_of_all_customers = user_count / (count from definition 1) * 100, rounded to 1 decimal. Tables: users, orders, subscriptions. Order by user_count descending.
Check your query with the warehouse's dry_run tool, then hand it in with submit.dry_runSELECT t.definition, t.user_count, round(t.user_count * 100.0 / tot.total_count, 1) as pct_of_all_customers FROM ( SELECT 'All customers (ever created)' as definition, (SELECT count(distinct u1.id) FROM users u1 WHERE u1.is_staff = false AND u1.created_at < timestamp '2026-01-01') as user_count UNION ALL SELECT 'Status = active', (SELECT count(distinct u2.id) FROM users u2 WHERE u2.is_staff = false AND u2.status = 'active') UNION ALL SELECT 'Placed at least one order, ever', (SELECT count(distinct u3.id) FROM users u3 WHERE u3.is_staff = false AND EXISTS (SELECT 1 FROM orders o3 WHERE o3.user_id = u3.id AND o3.placed_at < timestamp '2026-01-01')) UNION ALL SELECT 'Placed at least one order in trailing 12 months', (SELECT count(distinct u4.id) FROM users u4 WHERE u4.is_staff = false AND EXISTS (SELECT 1 FROM orders o4 WHERE o4.user_id = u4.id AND o4.placed_at >= timestamp '2025-01-01' AND o4.placed_at < timestamp '2026-01-01')) UNION ALL SELECT 'Has an active or trialing subscription', (SELECT count(distinct u5.id) FROM users u5 WHERE u5.is_staff = false AND EXISTS (SELECT 1 FROM subscriptions s5 WHERE s5.user_id = u5.id AND s5.status IN ('active','trialing'))) UNION ALL SELECT 'Logged in within last 90 days of data', (SELECT count(distinct u6.id) FROM users u6 WHERE u6.is_staff = false AND u6.last_login_at >= timestamp '2025-10-03' AND u6.last_login_at < timestamp '2026-01-01') ) t CROSS JOIN ( SELECT count(distinct u0.id) as total_count FROM users u0 WHERE u0.is_staff = false AND u0.created_at < timestamp '2026-01-01' ) tot ORDER BY t.user_count DESC, t.definition
STATUS: COMPILES (dry run on the empty schema, no data read) COLUMNS: definition, user_count, pct_of_all_customers
submitSELECT t.definition, t.user_count, round(t.user_count * 100.0 / tot.total_count, 1) as pct_of_all_customers FROM ( SELECT 'All customers (ever created)' as definition, (SELECT count(distinct u1.id) FROM users u1 WHERE u1.is_staff = false AND u1.created_at < timestamp '2026-01-01') as user_count UNION ALL SELECT 'Status = active', (SELECT count(distinct u2.id) FROM users u2 WHERE u2.is_staff = false AND u2.status = 'active') UNION ALL SELECT 'Placed at least one order, ever', (SELECT count(distinct u3.id) FROM users u3 WHERE u3.is_staff = false AND EXISTS (SELECT 1 FROM orders o3 WHERE o3.user_id = u3.id AND o3.placed_at < timestamp '2026-01-01')) UNION ALL SELECT 'Placed at least one order in trailing 12 months', (SELECT count(distinct u4.id) FROM users u4 WHERE u4.is_staff = false AND EXISTS (SELECT 1 FROM orders o4 WHERE o4.user_id = u4.id AND o4.placed_at >= timestamp '2025-01-01' AND o4.placed_at < timestamp '2026-01-01')) UNION ALL SELECT 'Has an active or trialing subscription', (SELECT count(distinct u5.id) FROM users u5 WHERE u5.is_staff = false AND EXISTS (SELECT 1 FROM subscriptions s5 WHERE s5.user_id = u5.id AND s5.status IN ('active','trialing'))) UNION ALL SELECT 'Logged in within last 90 days of data', (SELECT count(distinct u6.id) FROM users u6 WHERE u6.is_staff = false AND u6.last_login_at >= timestamp '2025-10-03' AND u6.last_login_at < timestamp '2026-01-01') ) t CROSS JOIN ( SELECT count(distinct u0.id) as total_count FROM users u0 WHERE u0.is_staff = false AND u0.created_at < timestamp '2026-01-01' ) tot ORDER BY t.user_count DESC, t.definition
Submitted to tonight's batch. Your work on this request is done.