Calculate treatment differences within enrollment strata
Original fictional practice · CC BY 4.0 · 2026-11-11

TASK
For each first-assignment user sum eligible outcome values, zero if absent. Per stratum return stratum,mean_A,mean_B,difference_B_minus_A rounded2. Both arms are present in each supplied stratum. Sort stratum.

OUTPUT
stratum, mean_A, mean_B, difference_B_minus_A

RULES
For each first-assignment user sum eligible outcome values, zero if absent. Per stratum return stratum,mean_A,mean_B,difference_B_minus_A rounded2. Both arms are present in each supplied stratum. Sort stratum.
Return exactly the declared columns and order. Money uses integer cents; time and date units follow the task and field dictionary. NULL is unknown and differs from numeric zero.
These are original fictional records and exercise policies. Scenario data may be shared with related tasks, whose decisions and output contracts differ.

FIELD DICTIONARY
assignments:
  id INTEGER — Stable source record identifier; not a row position.
  user_id INTEGER — Foreign business-record identifier; match to the named source key.
  variant TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  minute INTEGER — Elapsed UTC minute from the fictional scenario origin.
  device TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  stratum TEXT — Literal business key or category label. Match exactly and retain NULL where present.

outcomes:
  id INTEGER — Stable source record identifier; not a row position.
  user_id INTEGER — Foreign business-record identifier; match to the named source key.
  minute INTEGER — Elapsed UTC minute from the fictional scenario origin.
  value INTEGER — Measured numeric value; NULL means unobserved.
  exposed INTEGER — Exact integer business measurement. Its specific business rule and eligibility are declared in the task.
  error INTEGER — Exact integer business measurement. Its specific business rule and eligibility are declared in the task.

METHOD
For each first-assignment user sum eligible outcome values, zero if absent. Per stratum return stratum,mean_A,mean_B,difference_B_minus_A rounded2. Both arms are present in each supplied stratum. Sort stratum.
For the first output record, stratum = new; mean_A = 10; mean_B = 20; difference_B_minus_A = 10.
Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.

COMMON WRONG TURN
Pooling strata before comparing arms can confound the treatment difference with enrollment composition.

RESULT CHECK
For the first output record, stratum = new; mean_A = 10; mean_B = 20; difference_B_minus_A = 10.

Use setup.sql in a fresh SQLite database and run your own SELECT or WITH. reference.sql and expected.csv contain the full worked answer. All CSVs have UTF-8 headers; empty output fields represent NULL. The browser executes SQLite, not Excel formulas. No spreadsheet function engine is claimed.
