{
  "run_id": "banking-docs-c9aef3140970-exists-corrected",
  "rescored_run_id": "banking-docs-c9aef3140970",
  "authority": "Founder ruling D12, 2026-10-10: invalidated-run correction, re-scored from the cached responses with no new model calls.",
  "correction": "EXISTS is a predicate over a subquery, not a callable function; the corrected validator treats exp.Exists like And, Or and Not and changes nothing else.",
  "original_results_sha256": "1c198878adc94ffae18fd1efcb14dc4db9e6533a49225ddc0c97d5248ac40818",
  "cache_manifest_sha256": "cfb27f99ec61670b22a140cf3a25053daea6bfa778292d60d6d988c01637451f",
  "dataset_identity": "f937f3c0db0b2037d97e2fe000b6522daba5e9f597c30e70e8d8d7c8a9f2da67",
  "question_count": 40,
  "outcome_count": 80,
  "changed_outcomes": [
    {
      "question_id": "B35",
      "arm": "bare",
      "old_status": "query_denied",
      "new_status": "correct",
      "old_correct": false,
      "new_correct": true,
      "sql_has_exists": true
    }
  ],
  "original_summary": {
    "all": {
      "n": 40,
      "bare_correct": 26,
      "documented_correct": 33,
      "bare_accuracy": 0.65,
      "documented_accuracy": 0.825,
      "difference": 0.17499999999999993,
      "interval": [
        0.05,
        0.325
      ]
    },
    "by_tier": {
      "1": {
        "n": 6,
        "bare_correct": 5,
        "documented_correct": 6,
        "bare_accuracy": 0.8333333333333334,
        "documented_accuracy": 1.0,
        "difference": 0.16666666666666663,
        "interval": [
          0.0,
          0.5
        ]
      },
      "2": {
        "n": 30,
        "bare_correct": 21,
        "documented_correct": 27,
        "bare_accuracy": 0.7,
        "documented_accuracy": 0.9,
        "difference": 0.20000000000000007,
        "interval": [
          0.03333333333333333,
          0.36666666666666664
        ]
      },
      "3": {
        "n": 4,
        "bare_correct": 0,
        "documented_correct": 0,
        "bare_accuracy": 0.0,
        "documented_accuracy": 0.0,
        "difference": 0.0,
        "interval": [
          0.0,
          0.0
        ]
      }
    },
    "uncertainty": {
      "method": "paired percentile bootstrap over question IDs",
      "replicates": 10000,
      "seed": 7,
      "limitation": "Questions are purposive and related. This interval does not establish population generalization or variation across model reruns."
    },
    "analytical": {
      "n": 36,
      "bare_correct": 26,
      "documented_correct": 33,
      "bare_accuracy": 0.7222222222222222,
      "documented_accuracy": 0.9166666666666666,
      "difference": 0.19444444444444442,
      "interval": [
        0.05555555555555555,
        0.3611111111111111
      ]
    },
    "clarification": {
      "n": 4,
      "bare_correct": 0,
      "documented_correct": 0,
      "bare_accuracy": 0.0,
      "documented_accuracy": 0.0,
      "difference": 0.0,
      "interval": [
        0.0,
        0.0
      ]
    },
    "shared_summarizer_mapping": "Internal raw/governed keys map to bare/documented; both arms use the same raw-SQL adapter."
  },
  "summary": {
    "all": {
      "n": 40,
      "bare_correct": 27,
      "documented_correct": 33,
      "bare_accuracy": 0.675,
      "documented_accuracy": 0.825,
      "difference": 0.1499999999999999,
      "interval": [
        0.0,
        0.3
      ]
    },
    "by_tier": {
      "1": {
        "n": 6,
        "bare_correct": 5,
        "documented_correct": 6,
        "bare_accuracy": 0.8333333333333334,
        "documented_accuracy": 1.0,
        "difference": 0.16666666666666663,
        "interval": [
          0.0,
          0.5
        ]
      },
      "2": {
        "n": 30,
        "bare_correct": 22,
        "documented_correct": 27,
        "bare_accuracy": 0.7333333333333333,
        "documented_accuracy": 0.9,
        "difference": 0.16666666666666674,
        "interval": [
          -0.03333333333333333,
          0.36666666666666664
        ]
      },
      "3": {
        "n": 4,
        "bare_correct": 0,
        "documented_correct": 0,
        "bare_accuracy": 0.0,
        "documented_accuracy": 0.0,
        "difference": 0.0,
        "interval": [
          0.0,
          0.0
        ]
      }
    },
    "uncertainty": {
      "method": "paired percentile bootstrap over question IDs",
      "replicates": 10000,
      "seed": 7,
      "limitation": "Questions are purposive and related. This interval does not establish population generalization or variation across model reruns."
    },
    "analytical": {
      "n": 36,
      "bare_correct": 27,
      "documented_correct": 33,
      "bare_accuracy": 0.75,
      "documented_accuracy": 0.9166666666666666,
      "difference": 0.16666666666666663,
      "interval": [
        0.0,
        0.3333333333333333
      ]
    },
    "clarification": {
      "n": 4,
      "bare_correct": 0,
      "documented_correct": 0,
      "bare_accuracy": 0.0,
      "documented_accuracy": 0.0,
      "difference": 0.0,
      "interval": [
        0.0,
        0.0
      ]
    },
    "shared_summarizer_mapping": "Internal raw/governed keys map to bare/documented; both arms use the same raw-SQL adapter."
  },
  "twin_clustered": {
    "all": {
      "n": 40,
      "clusters": 32,
      "largest_cluster": 2,
      "difference": 0.15,
      "interval": [
        0.0,
        0.3142857142857143
      ]
    },
    "analytical": {
      "n": 36,
      "clusters": 28,
      "largest_cluster": 2,
      "difference": 0.16666666666666666,
      "interval": [
        0.0,
        0.35135135135135137
      ]
    }
  },
  "twin_rule": "Questions whose text is identical after replacing CAD and USD with one placeholder form one cluster; every other question is its own cluster.",
  "outcomes": [
    {
      "question_id": "B01",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT SUM(purchased_minor) FROM card_spend_daily WHERE currency = 'CAD' AND spend_date >= DATE '2026-07-01' AND spend_date < DATE '2026-08-01'",
      "rows": [
        [
          1342646
        ]
      ]
    },
    {
      "question_id": "B01",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(SUM(purchased_minor), 0) AS gross_card_spend_cad_july_2026 FROM card_spend_daily WHERE currency = 'CAD' AND spend_date >= DATE '2026-07-01' AND spend_date < DATE '2026-08-01'",
      "rows": [
        [
          1342646
        ]
      ]
    },
    {
      "question_id": "B02",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(SUM(purchased_minor), 0) AS gross_card_spend_usd_july_2026\nFROM card_spend_daily\nJOIN cards ON card_spend_daily.card_id = cards.card_id\nJOIN accounts ON cards.account_id = accounts.account_id\nWHERE card_spend_daily.spend_date >= DATE '2026-07-01'\n  AND card_spend_daily.spend_date < DATE '2026-08-01'\n  AND accounts.currency = 'USD'",
      "rows": [
        [
          580559
        ]
      ]
    },
    {
      "question_id": "B02",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT SUM(purchased_minor) FROM card_spend_daily WHERE currency = 'USD' AND spend_date >= DATE '2026-07-01' AND spend_date < DATE '2026-08-01'",
      "rows": [
        [
          580559
        ]
      ]
    },
    {
      "question_id": "B03",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(SUM(refunded_minor), 0) FROM card_spend_daily WHERE currency = 'CAD' AND spend_date >= DATE '2026-07-01' AND spend_date < DATE '2026-08-01'",
      "rows": [
        [
          64654
        ]
      ]
    },
    {
      "question_id": "B03",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(SUM(refunded_minor), 0) AS refunded_amount_cad FROM card_spend_daily WHERE currency = 'CAD' AND spend_date >= DATE '2026-07-01' AND spend_date < DATE '2026-08-01'",
      "rows": [
        [
          64654
        ]
      ]
    },
    {
      "question_id": "B04",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(SUM(net_spend_minor), 0) AS net_card_spend_cad FROM card_spend_daily WHERE currency = 'CAD' AND spend_date >= DATE '2026-07-01' AND spend_date < DATE '2026-08-01'",
      "rows": [
        [
          1277992
        ]
      ]
    },
    {
      "question_id": "B04",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(SUM(net_spend_minor), 0) AS net_card_spend_cad_july_2026 FROM card_spend_daily WHERE currency = 'CAD' AND spend_date >= DATE '2026-07-01' AND spend_date < DATE '2026-08-01'",
      "rows": [
        [
          1277992
        ]
      ]
    },
    {
      "question_id": "B05",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(SUM(net_spend_minor), 0) AS net_card_spend_usd_july_2026 FROM card_spend_daily WHERE currency = 'USD' AND spend_date >= DATE '2026-07-01' AND spend_date < DATE '2026-08-01'",
      "rows": [
        [
          554332
        ]
      ]
    },
    {
      "question_id": "B05",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(SUM(net_spend_minor), 0) AS net_card_spend_usd_july_2026\nFROM card_spend_daily\nWHERE currency = 'USD'\n  AND spend_date >= DATE '2026-07-01'\n  AND spend_date < DATE '2026-08-01'",
      "rows": [
        [
          554332
        ]
      ]
    },
    {
      "question_id": "B06",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COUNT(*) FROM transactions WHERE event_kind = 'purchase' AND status = 'posted' AND currency = 'CAD' AND posted_at >= '2026-07-01' AND posted_at < '2026-08-01' AND card_id IS NOT NULL",
      "rows": [
        [
          286
        ]
      ]
    },
    {
      "question_id": "B06",
      "arm": "bare",
      "kind": "analytical",
      "correct": false,
      "status": "wrong_answer",
      "sql": "SELECT COUNT(*) FROM transactions WHERE currency = 'CAD' AND event_kind = 'purchase' AND EXTRACT(YEAR FROM occurred_at) = 2026 AND EXTRACT(MONTH FROM occurred_at) = 7",
      "rows": [
        [
          342
        ]
      ]
    },
    {
      "question_id": "B07",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(c.category_name, 'Uncategorized') AS category_label, SUM(cs.net_spend_minor) AS net_minor_units FROM card_spend_daily cs LEFT JOIN categories c ON cs.category_id = c.category_id WHERE cs.currency = 'CAD' AND cs.spend_date >= DATE '2026-07-01' AND cs.spend_date < DATE '2026-08-01' GROUP BY category_label HAVING SUM(cs.net_spend_minor) <> 0",
      "rows": [
        [
          "Software",
          224575
        ],
        [
          "Travel",
          249615
        ],
        [
          "Supplies",
          219068
        ],
        [
          "Meals",
          293557
        ],
        [
          "Uncategorized",
          291177
        ]
      ]
    },
    {
      "question_id": "B07",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(c.category_name, 'Uncategorized') AS category_label, SUM(cs.net_spend_minor) AS net_minor_units\nFROM card_spend_daily cs\nLEFT JOIN categories c ON cs.category_id = c.category_id\nWHERE cs.currency = 'CAD' AND cs.spend_date >= DATE '2026-07-01' AND cs.spend_date < DATE '2026-08-01'\nGROUP BY category_label\nHAVING SUM(cs.net_spend_minor) != 0",
      "rows": [
        [
          "Software",
          224575
        ],
        [
          "Travel",
          249615
        ],
        [
          "Supplies",
          219068
        ],
        [
          "Meals",
          293557
        ],
        [
          "Uncategorized",
          291177
        ]
      ]
    },
    {
      "question_id": "B08",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(c.category_name, 'Uncategorized') AS category_label, SUM(cs.net_spend_minor) AS net_minor_units\nFROM card_spend_daily cs\nLEFT JOIN categories c ON cs.category_id = c.category_id\nJOIN cards cd ON cs.card_id = cd.card_id\nJOIN accounts a ON cd.account_id = a.account_id\nWHERE cs.spend_date >= DATE '2026-07-01' AND cs.spend_date < DATE '2026-08-01' AND a.currency = 'USD'\nGROUP BY category_label\nHAVING SUM(cs.net_spend_minor) != 0",
      "rows": [
        [
          "Meals",
          111588
        ],
        [
          "Travel",
          117967
        ],
        [
          "Software",
          101312
        ],
        [
          "Supplies",
          94490
        ],
        [
          "Uncategorized",
          128975
        ]
      ]
    },
    {
      "question_id": "B08",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(c.category_name, 'Uncategorized') AS category_label, SUM(cs.net_spend_minor) AS net_minor_units\nFROM card_spend_daily cs\nLEFT JOIN categories c ON cs.category_id = c.category_id\nWHERE cs.currency = 'USD' AND cs.spend_date >= DATE '2026-07-01' AND cs.spend_date < DATE '2026-08-01'\nGROUP BY category_label\nHAVING SUM(cs.net_spend_minor) <> 0",
      "rows": [
        [
          "Meals",
          111588
        ],
        [
          "Travel",
          117967
        ],
        [
          "Software",
          101312
        ],
        [
          "Supplies",
          94490
        ],
        [
          "Uncategorized",
          128975
        ]
      ]
    },
    {
      "question_id": "B09",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT a.organization_id, SUM(csd.net_spend_minor) AS net_spend_minor\nFROM card_spend_daily csd\nJOIN accounts a ON csd.account_id = a.account_id\nWHERE csd.currency = 'CAD'\n  AND csd.spend_date >= DATE '2026-07-01'\n  AND csd.spend_date < DATE '2026-08-01'\nGROUP BY a.organization_id\nHAVING SUM(csd.net_spend_minor) != 0",
      "rows": [
        [
          "org_01",
          230735
        ],
        [
          "org_02",
          203006
        ],
        [
          "org_03",
          253869
        ],
        [
          "org_04",
          250691
        ],
        [
          "org_05",
          243071
        ],
        [
          "org_06",
          96620
        ]
      ]
    },
    {
      "question_id": "B09",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT a.organization_id, SUM(csd.net_spend_minor) AS net_spend_minor\nFROM card_spend_daily csd\nJOIN cards c ON csd.card_id = c.card_id\nJOIN accounts a ON c.account_id = a.account_id\nWHERE csd.spend_date >= DATE '2026-07-01' AND csd.spend_date < DATE '2026-08-01'\n  AND csd.currency = 'CAD'\nGROUP BY a.organization_id\nHAVING SUM(csd.purchase_count) > 0",
      "rows": [
        [
          "org_01",
          230735
        ],
        [
          "org_02",
          203006
        ],
        [
          "org_03",
          253869
        ],
        [
          "org_04",
          250691
        ],
        [
          "org_05",
          243071
        ],
        [
          "org_06",
          96620
        ]
      ]
    },
    {
      "question_id": "B10",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT a.organization_id, SUM(csd.net_spend_minor) AS net_spend_minor\nFROM card_spend_daily csd\nJOIN cards c ON csd.card_id = c.card_id\nJOIN accounts a ON c.account_id = a.account_id\nWHERE csd.spend_date >= DATE '2026-07-01' AND csd.spend_date < DATE '2026-08-01'\n  AND csd.currency = 'USD'\nGROUP BY a.organization_id\nHAVING SUM(csd.purchase_count) > 0",
      "rows": [
        [
          "org_01",
          106600
        ],
        [
          "org_02",
          127490
        ],
        [
          "org_03",
          88313
        ],
        [
          "org_05",
          127957
        ],
        [
          "org_04",
          103972
        ]
      ]
    },
    {
      "question_id": "B10",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT a.organization_id, SUM(csd.net_spend_minor) AS net_spend_minor\nFROM card_spend_daily csd\nJOIN accounts a ON csd.account_id = a.account_id\nWHERE csd.currency = 'USD'\n  AND csd.spend_date >= DATE '2026-07-01'\n  AND csd.spend_date < DATE '2026-08-01'\nGROUP BY a.organization_id\nHAVING SUM(csd.net_spend_minor) != 0",
      "rows": [
        [
          "org_01",
          106600
        ],
        [
          "org_02",
          127490
        ],
        [
          "org_03",
          88313
        ],
        [
          "org_05",
          127957
        ],
        [
          "org_04",
          103972
        ]
      ]
    },
    {
      "question_id": "B11",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT a.account_id, COALESCE(SUM(csd.net_spend_minor), 0) AS net_minor_units\nFROM accounts a\nLEFT JOIN card_spend_daily csd ON a.account_id = csd.account_id AND csd.currency = 'CAD' AND csd.spend_date >= DATE '2026-07-01' AND csd.spend_date <= DATE '2026-07-31'\nWHERE a.currency = 'CAD'\nGROUP BY a.account_id",
      "rows": [
        [
          "acct_001",
          129813
        ],
        [
          "acct_002",
          100922
        ],
        [
          "acct_004",
          106104
        ],
        [
          "acct_005",
          96902
        ],
        [
          "acct_007",
          130636
        ],
        [
          "acct_008",
          123233
        ],
        [
          "acct_011",
          126577
        ],
        [
          "acct_013",
          120981
        ],
        [
          "acct_014",
          122090
        ],
        [
          "acct_016",
          96620
        ],
        [
          "acct_010",
          124114
        ],
        [
          "acct_019",
          0
        ],
        [
          "acct_017",
          0
        ]
      ]
    },
    {
      "question_id": "B11",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT a.account_id, COALESCE(SUM(csd.net_spend_minor), 0) AS net_card_spend_minor\nFROM accounts a\nLEFT JOIN cards c ON a.account_id = c.account_id\nLEFT JOIN card_spend_daily csd ON c.card_id = csd.card_id AND csd.spend_date >= DATE '2026-07-01' AND csd.spend_date < DATE '2026-08-01'\nWHERE a.currency = 'CAD'\nGROUP BY a.account_id",
      "rows": [
        [
          "acct_001",
          129813
        ],
        [
          "acct_002",
          100922
        ],
        [
          "acct_004",
          106104
        ],
        [
          "acct_005",
          96902
        ],
        [
          "acct_007",
          130636
        ],
        [
          "acct_008",
          123233
        ],
        [
          "acct_011",
          126577
        ],
        [
          "acct_013",
          120981
        ],
        [
          "acct_014",
          122090
        ],
        [
          "acct_016",
          96620
        ],
        [
          "acct_010",
          124114
        ],
        [
          "acct_017",
          0
        ],
        [
          "acct_019",
          0
        ]
      ]
    },
    {
      "question_id": "B12",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT a.account_id, COALESCE(SUM(csd.net_spend_minor), 0) AS net_card_spend_minor\nFROM accounts a\nLEFT JOIN cards c ON a.account_id = c.account_id\nLEFT JOIN card_spend_daily csd ON c.card_id = csd.card_id AND csd.spend_date >= DATE '2026-07-01' AND csd.spend_date < DATE '2026-08-01'\nWHERE a.currency = 'USD'\nGROUP BY a.account_id",
      "rows": [
        [
          "acct_003",
          106600
        ],
        [
          "acct_006",
          127490
        ],
        [
          "acct_009",
          88313
        ],
        [
          "acct_015",
          127957
        ],
        [
          "acct_012",
          103972
        ],
        [
          "acct_018",
          0
        ]
      ]
    },
    {
      "question_id": "B12",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT a.account_id, COALESCE(SUM(csd.net_spend_minor), 0) AS net_spend_minor\nFROM accounts a\nLEFT JOIN card_spend_daily csd ON a.account_id = csd.account_id AND csd.currency = 'USD' AND csd.spend_date >= DATE '2026-07-01' AND csd.spend_date <= DATE '2026-07-31'\nWHERE a.currency = 'USD'\nGROUP BY a.account_id",
      "rows": [
        [
          "acct_003",
          106600
        ],
        [
          "acct_006",
          127490
        ],
        [
          "acct_009",
          88313
        ],
        [
          "acct_015",
          127957
        ],
        [
          "acct_012",
          103972
        ],
        [
          "acct_018",
          0
        ]
      ]
    },
    {
      "question_id": "B13",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT STRFTIME(spend_date, '%Y-%m-%d') AS date, SUM(net_spend_minor) AS net_spend_minor FROM card_spend_daily WHERE currency = 'CAD' AND spend_date >= DATE '2026-07-01' AND spend_date < DATE '2026-08-01' GROUP BY spend_date ORDER BY spend_date ASC",
      "rows": [
        [
          "2026-07-01",
          66420
        ],
        [
          "2026-07-02",
          48706
        ],
        [
          "2026-07-03",
          29351
        ],
        [
          "2026-07-04",
          43817
        ],
        [
          "2026-07-05",
          25257
        ],
        [
          "2026-07-06",
          47767
        ],
        [
          "2026-07-07",
          54913
        ],
        [
          "2026-07-08",
          37942
        ],
        [
          "2026-07-09",
          37747
        ],
        [
          "2026-07-10",
          42269
        ],
        [
          "2026-07-11",
          58518
        ],
        [
          "2026-07-12",
          27667
        ],
        [
          "2026-07-13",
          52979
        ],
        [
          "2026-07-14",
          49789
        ],
        [
          "2026-07-15",
          25343
        ],
        [
          "2026-07-16",
          29279
        ],
        [
          "2026-07-17",
          41628
        ],
        [
          "2026-07-18",
          46129
        ],
        [
          "2026-07-19",
          34962
        ],
        [
          "2026-07-20",
          43742
        ],
        [
          "2026-07-21",
          40948
        ],
        [
          "2026-07-22",
          45552
        ],
        [
          "2026-07-23",
          26826
        ],
        [
          "2026-07-24",
          49751
        ],
        [
          "2026-07-25",
          30147
        ],
        [
          "2026-07-26",
          34592
        ],
        [
          "2026-07-27",
          61314
        ],
        [
          "2026-07-28",
          38322
        ],
        [
          "2026-07-29",
          37432
        ],
        [
          "2026-07-30",
          30821
        ],
        [
          "2026-07-31",
          38062
        ]
      ]
    },
    {
      "question_id": "B13",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT spend_date AS date, SUM(net_spend_minor) AS net_card_spend_minor\nFROM card_spend_daily\nWHERE currency = 'CAD' AND spend_date >= '2026-07-01' AND spend_date < '2026-08-01'\nGROUP BY spend_date\nORDER BY spend_date ASC",
      "rows": [
        [
          "2026-07-01",
          66420
        ],
        [
          "2026-07-02",
          48706
        ],
        [
          "2026-07-03",
          29351
        ],
        [
          "2026-07-04",
          43817
        ],
        [
          "2026-07-05",
          25257
        ],
        [
          "2026-07-06",
          47767
        ],
        [
          "2026-07-07",
          54913
        ],
        [
          "2026-07-08",
          37942
        ],
        [
          "2026-07-09",
          37747
        ],
        [
          "2026-07-10",
          42269
        ],
        [
          "2026-07-11",
          58518
        ],
        [
          "2026-07-12",
          27667
        ],
        [
          "2026-07-13",
          52979
        ],
        [
          "2026-07-14",
          49789
        ],
        [
          "2026-07-15",
          25343
        ],
        [
          "2026-07-16",
          29279
        ],
        [
          "2026-07-17",
          41628
        ],
        [
          "2026-07-18",
          46129
        ],
        [
          "2026-07-19",
          34962
        ],
        [
          "2026-07-20",
          43742
        ],
        [
          "2026-07-21",
          40948
        ],
        [
          "2026-07-22",
          45552
        ],
        [
          "2026-07-23",
          26826
        ],
        [
          "2026-07-24",
          49751
        ],
        [
          "2026-07-25",
          30147
        ],
        [
          "2026-07-26",
          34592
        ],
        [
          "2026-07-27",
          61314
        ],
        [
          "2026-07-28",
          38322
        ],
        [
          "2026-07-29",
          37432
        ],
        [
          "2026-07-30",
          30821
        ],
        [
          "2026-07-31",
          38062
        ]
      ]
    },
    {
      "question_id": "B14",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT account_id, SUM(net_spend_minor) AS net_spend_minor\nFROM card_spend_daily\nWHERE currency = 'CAD' AND spend_date >= DATE '2026-07-01' AND spend_date < DATE '2026-08-01'\nGROUP BY account_id\nORDER BY net_spend_minor DESC, account_id ASC\nLIMIT 3",
      "rows": [
        [
          "acct_007",
          130636
        ],
        [
          "acct_001",
          129813
        ],
        [
          "acct_011",
          126577
        ]
      ]
    },
    {
      "question_id": "B14",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT account_id, SUM(net_spend_minor) AS net_spend_minor FROM card_spend_daily WHERE currency = 'CAD' AND spend_date >= DATE '2026-07-01' AND spend_date <= DATE '2026-07-31' GROUP BY account_id ORDER BY net_spend_minor DESC, account_id ASC LIMIT 3",
      "rows": [
        [
          "acct_007",
          130636
        ],
        [
          "acct_001",
          129813
        ],
        [
          "acct_011",
          126577
        ]
      ]
    },
    {
      "question_id": "B15",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(c.category_name, 'Uncategorized') AS category_label, SUM(cs.net_spend_minor) AS net_minor_units\nFROM card_spend_daily cs\nLEFT JOIN categories c ON cs.category_id = c.category_id\nWHERE cs.currency = 'CAD' AND EXTRACT(YEAR FROM cs.spend_date) = 2026 AND EXTRACT(MONTH FROM cs.spend_date) = 7\nGROUP BY category_label\nORDER BY net_minor_units DESC, category_label ASC\nLIMIT 3",
      "rows": [
        [
          "Meals",
          293557
        ],
        [
          "Uncategorized",
          291177
        ],
        [
          "Travel",
          249615
        ]
      ]
    },
    {
      "question_id": "B15",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(c.category_name, 'Uncategorized') AS category_label, SUM(cs.net_spend_minor) AS net_minor_units\nFROM card_spend_daily cs\nLEFT JOIN categories c ON cs.category_id = c.category_id\nWHERE cs.spend_date >= DATE '2026-07-01' AND cs.spend_date < DATE '2026-08-01' AND cs.currency = 'CAD'\nGROUP BY category_label\nORDER BY net_minor_units DESC, category_label ASC\nLIMIT 3",
      "rows": [
        [
          "Meals",
          293557
        ],
        [
          "Uncategorized",
          291177
        ],
        [
          "Travel",
          249615
        ]
      ]
    },
    {
      "question_id": "B16",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT a.account_id, COUNT(c.card_id) AS active_card_count\nFROM accounts a\nLEFT JOIN cards c ON a.account_id = c.account_id AND c.card_status = 'active'\nWHERE a.currency = 'CAD'\nGROUP BY a.account_id",
      "rows": [
        [
          "acct_001",
          2
        ],
        [
          "acct_002",
          2
        ],
        [
          "acct_004",
          2
        ],
        [
          "acct_005",
          1
        ],
        [
          "acct_007",
          2
        ],
        [
          "acct_008",
          2
        ],
        [
          "acct_010",
          1
        ],
        [
          "acct_011",
          2
        ],
        [
          "acct_013",
          2
        ],
        [
          "acct_014",
          2
        ],
        [
          "acct_016",
          2
        ],
        [
          "acct_017",
          2
        ],
        [
          "acct_019",
          0
        ]
      ]
    },
    {
      "question_id": "B16",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT a.account_id, COUNT(c.card_id) AS active_card_count FROM accounts a LEFT JOIN cards c ON a.account_id = c.account_id AND c.card_status = 'active' WHERE a.currency = 'CAD' GROUP BY a.account_id",
      "rows": [
        [
          "acct_001",
          2
        ],
        [
          "acct_002",
          2
        ],
        [
          "acct_004",
          2
        ],
        [
          "acct_005",
          1
        ],
        [
          "acct_007",
          2
        ],
        [
          "acct_008",
          2
        ],
        [
          "acct_010",
          1
        ],
        [
          "acct_011",
          2
        ],
        [
          "acct_013",
          2
        ],
        [
          "acct_014",
          2
        ],
        [
          "acct_016",
          2
        ],
        [
          "acct_017",
          2
        ],
        [
          "acct_019",
          0
        ]
      ]
    },
    {
      "question_id": "B17",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT currency, COUNT(*) FILTER (WHERE card_status = 'active') AS active_card_count FROM cards RIGHT JOIN accounts USING(account_id) GROUP BY currency ORDER BY currency",
      "rows": [
        [
          "CAD",
          22
        ],
        [
          "USD",
          5
        ]
      ]
    },
    {
      "question_id": "B17",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT a.currency, COUNT(c.card_id) AS active_card_count\nFROM accounts a\nLEFT JOIN cards c ON a.account_id = c.account_id AND c.card_status = 'active'\nGROUP BY a.currency\nORDER BY a.currency",
      "rows": [
        [
          "CAD",
          22
        ],
        [
          "USD",
          5
        ]
      ]
    },
    {
      "question_id": "B18",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT p.transaction_id AS original_transaction_id, p.amount_minor AS original_purchase_amount, SUM(r.amount_minor) AS total_refunded_in_july\nFROM transactions p\nJOIN transactions r ON r.related_transaction_id = p.transaction_id\nWHERE p.event_kind = 'purchase'\n  AND p.currency = 'CAD'\n  AND r.event_kind = 'refund'\n  AND r.status = 'posted'\n  AND r.posted_at >= '2026-07-01' AND r.posted_at < '2026-08-01'\nGROUP BY p.transaction_id, p.amount_minor",
      "rows": [
        [
          "txn_00007",
          1520,
          506
        ],
        [
          "txn_00015",
          7754,
          2584
        ],
        [
          "txn_00030",
          8191,
          2730
        ],
        [
          "txn_00041",
          9577,
          3192
        ],
        [
          "txn_00049",
          1443,
          481
        ],
        [
          "txn_00057",
          4566,
          1522
        ],
        [
          "txn_00065",
          546,
          182
        ],
        [
          "txn_00118",
          5858,
          1952
        ],
        [
          "txn_00126",
          3656,
          1218
        ],
        [
          "txn_00134",
          6827,
          2275
        ],
        [
          "txn_00145",
          5990,
          1996
        ],
        [
          "txn_00153",
          3000,
          1000
        ],
        [
          "txn_00212",
          7369,
          2456
        ],
        [
          "txn_00220",
          6360,
          2120
        ],
        [
          "txn_00228",
          9820,
          3273
        ],
        [
          "txn_00236",
          5333,
          1777
        ],
        [
          "txn_00247",
          6544,
          2181
        ],
        [
          "txn_00262",
          5017,
          1672
        ],
        [
          "txn_00270",
          6727,
          2242
        ],
        [
          "txn_00316",
          960,
          320
        ],
        [
          "txn_00324",
          7040,
          2346
        ],
        [
          "txn_00332",
          3863,
          1287
        ],
        [
          "txn_00340",
          3740,
          1246
        ],
        [
          "txn_00351",
          5838,
          1946
        ],
        [
          "txn_00359",
          1907,
          635
        ],
        [
          "txn_00367",
          2869,
          956
        ],
        [
          "txn_00418",
          5596,
          1865
        ],
        [
          "txn_00426",
          5476,
          1825
        ],
        [
          "txn_00434",
          5894,
          1964
        ],
        [
          "txn_00442",
          4394,
          1464
        ],
        [
          "txn_00453",
          8460,
          2820
        ],
        [
          "txn_00461",
          7231,
          2410
        ],
        [
          "txn_00469",
          1055,
          351
        ],
        [
          "txn_00477",
          2564,
          854
        ],
        [
          "txn_00522",
          3059,
          1019
        ],
        [
          "txn_00530",
          3720,
          1240
        ],
        [
          "txn_00538",
          4208,
          1402
        ],
        [
          "boundary_june_occurrence",
          12345,
          3345
        ]
      ]
    },
    {
      "question_id": "B18",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "WITH RefundsInJuly AS (\n  SELECT\n    related_transaction_id AS original_transaction_id,\n    SUM(amount_minor) AS total_refunded_july\n  FROM transactions\n  WHERE direction = 'credit'\n    AND currency = 'CAD'\n    AND status = 'posted'\n    AND event_kind = 'refund'\n    AND EXTRACT(YEAR FROM occurred_at) = 2026\n    AND EXTRACT(MONTH FROM occurred_at) = 7\n  GROUP BY related_transaction_id\n),\nOriginalPurchases AS (\n  SELECT\n    transaction_id,\n    amount_minor AS original_purchase_amount\n  FROM transactions\n  WHERE direction = 'debit'\n    AND currency = 'CAD'\n    AND status = 'posted'\n    AND event_kind = 'purchase'\n)\nSELECT\n  o.transaction_id AS original_transaction_id,\n  o.original_purchase_amount,\n  r.total_refunded_july\nFROM OriginalPurchases o\nJOIN RefundsInJuly r ON o.transaction_id = r.original_transaction_id",
      "rows": [
        [
          "txn_00007",
          1520,
          506
        ],
        [
          "txn_00015",
          7754,
          2584
        ],
        [
          "txn_00030",
          8191,
          2730
        ],
        [
          "txn_00041",
          9577,
          3192
        ],
        [
          "txn_00049",
          1443,
          481
        ],
        [
          "txn_00057",
          4566,
          1522
        ],
        [
          "txn_00065",
          546,
          182
        ],
        [
          "txn_00118",
          5858,
          1952
        ],
        [
          "txn_00126",
          3656,
          1218
        ],
        [
          "txn_00134",
          6827,
          2275
        ],
        [
          "txn_00145",
          5990,
          1996
        ],
        [
          "txn_00153",
          3000,
          1000
        ],
        [
          "txn_00212",
          7369,
          2456
        ],
        [
          "txn_00220",
          6360,
          2120
        ],
        [
          "txn_00228",
          9820,
          3273
        ],
        [
          "txn_00236",
          5333,
          1777
        ],
        [
          "txn_00247",
          6544,
          2181
        ],
        [
          "txn_00262",
          5017,
          1672
        ],
        [
          "txn_00270",
          6727,
          2242
        ],
        [
          "txn_00316",
          960,
          320
        ],
        [
          "txn_00324",
          7040,
          2346
        ],
        [
          "txn_00332",
          3863,
          1287
        ],
        [
          "txn_00340",
          3740,
          1246
        ],
        [
          "txn_00351",
          5838,
          1946
        ],
        [
          "txn_00359",
          1907,
          635
        ],
        [
          "txn_00367",
          2869,
          956
        ],
        [
          "txn_00418",
          5596,
          1865
        ],
        [
          "txn_00426",
          5476,
          1825
        ],
        [
          "txn_00434",
          5894,
          1964
        ],
        [
          "txn_00442",
          4394,
          1464
        ],
        [
          "txn_00453",
          8460,
          2820
        ],
        [
          "txn_00461",
          7231,
          2410
        ],
        [
          "txn_00469",
          1055,
          351
        ],
        [
          "txn_00477",
          2564,
          854
        ],
        [
          "txn_00522",
          3059,
          1019
        ],
        [
          "txn_00530",
          3720,
          1240
        ],
        [
          "txn_00538",
          4208,
          1402
        ],
        [
          "boundary_june_occurrence",
          12345,
          3345
        ]
      ]
    },
    {
      "question_id": "B19",
      "arm": "bare",
      "kind": "analytical",
      "correct": false,
      "status": "wrong_answer",
      "sql": "SELECT COUNT(DISTINCT t1.transaction_id) AS count_distinct_cad_purchases_with_refund FROM transactions t1 JOIN transactions t2 ON t1.transaction_id = t2.related_transaction_id WHERE t1.direction = 'credit' AND t1.currency = 'CAD' AND t1.status = 'posted' AND t2.direction = 'debit' AND t2.status = 'posted' AND t2.occurred_at >= '2026-07-01' AND t2.occurred_at < '2026-08-01'",
      "rows": [
        [
          0
        ]
      ]
    },
    {
      "question_id": "B19",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COUNT(DISTINCT t1.transaction_id) AS count_refunded_purchases\nFROM transactions t1\nJOIN transactions t2 ON t2.related_transaction_id = t1.transaction_id\nWHERE t1.currency = 'CAD'\n  AND t1.event_kind = 'purchase'\n  AND t1.status = 'posted'\n  AND t2.event_kind = 'refund'\n  AND t2.status = 'posted'\n  AND t2.posted_at >= '2026-07-01' AND t2.posted_at < '2026-08-01'",
      "rows": [
        [
          38
        ]
      ]
    },
    {
      "question_id": "B20",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(SUM(amount_minor), 0) AS deposit_amount_minor FROM transactions WHERE currency = 'CAD' AND event_kind = 'deposit' AND status = 'posted' AND posted_at >= '2026-07-01' AND posted_at < '2026-08-01'",
      "rows": [
        [
          769596
        ]
      ]
    },
    {
      "question_id": "B20",
      "arm": "bare",
      "kind": "analytical",
      "correct": false,
      "status": "wrong_answer",
      "sql": "SELECT COALESCE(SUM(amount_minor), 0) AS deposit_amount_minor FROM transactions WHERE direction = 'inbound' AND currency = 'CAD' AND occurred_at >= '2026-07-01' AND occurred_at < '2026-08-01' AND status = 'posted'",
      "rows": [
        [
          0
        ]
      ]
    },
    {
      "question_id": "B21",
      "arm": "bare",
      "kind": "analytical",
      "correct": false,
      "status": "wrong_answer",
      "sql": "SELECT COALESCE(SUM(amount_minor), 0) AS deposit_amount_minor FROM transactions WHERE direction = 'inbound' AND status = 'posted' AND currency = 'USD' AND occurred_at >= '2026-07-01' AND occurred_at < '2026-08-01'",
      "rows": [
        [
          0
        ]
      ]
    },
    {
      "question_id": "B21",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(SUM(amount_minor), 0) AS deposit_amount_usd FROM transactions WHERE currency = 'USD' AND event_kind = 'deposit' AND status = 'posted' AND posted_at >= '2026-07-01' AND posted_at < '2026-08-01'",
      "rows": [
        [
          320665
        ]
      ]
    },
    {
      "question_id": "B22",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(SUM(amount_minor), 0) AS withdrawal_amount_minor FROM transactions WHERE event_kind = 'withdrawal' AND currency = 'CAD' AND status = 'posted' AND posted_at >= '2026-07-01' AND posted_at < '2026-08-01'",
      "rows": [
        [
          12084
        ]
      ]
    },
    {
      "question_id": "B22",
      "arm": "bare",
      "kind": "analytical",
      "correct": false,
      "status": "wrong_answer",
      "sql": "SELECT COALESCE(SUM(amount_minor), 0) AS withdrawal_amount_minor FROM transactions WHERE currency = 'CAD' AND direction = 'outbound' AND occurred_at >= '2026-07-01' AND occurred_at < '2026-08-01'",
      "rows": [
        [
          0
        ]
      ]
    },
    {
      "question_id": "B23",
      "arm": "bare",
      "kind": "analytical",
      "correct": false,
      "status": "wrong_answer",
      "sql": "SELECT COALESCE(SUM(CASE WHEN direction = 'inbound' THEN amount_minor ELSE -amount_minor END), 0) AS net_external_cash_flow_minor FROM transactions WHERE currency = 'CAD' AND occurred_at >= '2026-07-01' AND occurred_at < '2026-08-01' AND event_kind = 'external' AND status = 'posted'",
      "rows": [
        [
          0
        ]
      ]
    },
    {
      "question_id": "B23",
      "arm": "documented",
      "kind": "analytical",
      "correct": false,
      "status": "execution_error",
      "sql": "SELECT COALESCE(SUM(CASE WHEN direction = 'credit' THEN amount_minor ELSE -amount_minor END), 0) AS net_external_cash_flow_cad_minor\nFROM transactions\nJOIN accounts USING (account_id)\nWHERE currency = 'CAD'\n  AND status = 'posted'\n  AND event_kind != 'transfer'\n  AND posted_at >= '2026-07-01 00:00:00'\n  AND posted_at < '2026-08-01 00:00:00'",
      "rows": null
    },
    {
      "question_id": "B24",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT SUM(CASE WHEN direction = 'credit' THEN amount_minor ELSE -amount_minor END) AS net_external_cash_flow_usd\nFROM transactions\nWHERE currency = 'USD'\n  AND status = 'posted'\n  AND event_kind != 'transfer'\n  AND posted_at >= '2026-07-01 00:00:00'\n  AND posted_at < '2026-08-01 00:00:00'",
      "rows": [
        [
          -238702
        ]
      ]
    },
    {
      "question_id": "B24",
      "arm": "bare",
      "kind": "analytical",
      "correct": false,
      "status": "wrong_answer",
      "sql": "SELECT COALESCE(SUM(CASE WHEN direction = 'inbound' THEN amount_minor ELSE -amount_minor END), 0) AS net_external_cash_flow_usd_minor FROM transactions WHERE currency = 'USD' AND occurred_at >= '2026-07-01' AND occurred_at < '2026-08-01' AND event_kind = 'external' AND status = 'posted'",
      "rows": [
        [
          0
        ]
      ]
    },
    {
      "question_id": "B25",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT SUM(ABS(amount_minor)) AS internal_transfer_volume_minor FROM (SELECT DISTINCT transfer_group_id, amount_minor FROM transactions WHERE currency = 'CAD' AND event_kind = 'transfer' AND status = 'posted' AND DATE_TRUNC('month', occurred_at) = DATE '2026-07-01' AND transfer_group_id IS NOT NULL)",
      "rows": [
        [
          13910
        ]
      ]
    },
    {
      "question_id": "B25",
      "arm": "documented",
      "kind": "analytical",
      "correct": false,
      "status": "execution_error",
      "sql": "SELECT SUM(t.amount_minor) AS internal_transfer_volume_cad_july_2026\nFROM (\n  SELECT DISTINCT tg.transfer_group_id, t.amount_minor\n  FROM transactions t\n  JOIN transactions t2 ON t.transfer_group_id = t2.transfer_group_id\n  WHERE t.currency = 'CAD'\n    AND t.event_kind = 'transfer'\n    AND t.status = 'posted'\n    AND t.posted_at >= '2026-07-01' AND t.posted_at < '2026-08-01'\n    AND t.direction = 'debit'\n) tg",
      "rows": null
    },
    {
      "question_id": "B26",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT currency, COUNT(DISTINCT transfer_group_id) AS transfer_count\nFROM transactions\nWHERE event_kind = 'transfer'\n  AND status = 'posted'\n  AND posted_at >= '2026-07-01' AND posted_at < '2026-08-01'\nGROUP BY currency",
      "rows": [
        [
          "CAD",
          4
        ],
        [
          "USD",
          4
        ]
      ]
    },
    {
      "question_id": "B26",
      "arm": "bare",
      "kind": "analytical",
      "correct": false,
      "status": "wrong_answer",
      "sql": "SELECT currency, COUNT(DISTINCT transfer_group_id) AS transfer_count FROM transactions WHERE event_kind = 'transfer' AND status = 'completed' AND DATE(posted_at) >= DATE '2026-07-01' AND DATE(posted_at) < DATE '2026-08-01' GROUP BY currency",
      "rows": []
    },
    {
      "question_id": "B27",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT SUM(closing_minor) FROM account_daily WHERE balance_date = DATE '2026-07-31' AND currency = 'CAD'",
      "rows": [
        [
          125676
        ]
      ]
    },
    {
      "question_id": "B27",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT SUM(closing_minor) FROM account_daily WHERE balance_date = DATE '2026-07-31' AND currency = 'CAD'",
      "rows": [
        [
          125676
        ]
      ]
    },
    {
      "question_id": "B28",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT SUM(closing_minor) FROM account_daily WHERE balance_date = DATE '2026-07-31' AND currency = 'USD'",
      "rows": [
        [
          20113
        ]
      ]
    },
    {
      "question_id": "B28",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT SUM(closing_minor) FROM account_daily WHERE balance_date = DATE '2026-07-31' AND currency = 'USD'",
      "rows": [
        [
          20113
        ]
      ]
    },
    {
      "question_id": "B29",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT SUM(opening_minor) FROM account_daily WHERE balance_date = DATE '2026-07-01' AND currency = 'CAD'",
      "rows": [
        [
          646156
        ]
      ]
    },
    {
      "question_id": "B29",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT SUM(opening_balance_minor) FROM accounts WHERE currency = 'CAD'",
      "rows": [
        [
          646156
        ]
      ]
    },
    {
      "question_id": "B30",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT SUM(closing_minor) FROM account_daily WHERE balance_date = DATE '2026-07-15' AND currency = 'CAD'",
      "rows": [
        [
          308471
        ]
      ]
    },
    {
      "question_id": "B30",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT SUM(closing_minor) FROM account_daily WHERE balance_date = DATE '2026-07-15' AND currency = 'CAD'",
      "rows": [
        [
          308471
        ]
      ]
    },
    {
      "question_id": "B31",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(SUM(purchased_minor), 0) FROM card_spend_daily WHERE spend_date = DATE '2026-07-01' AND currency = 'CAD'",
      "rows": [
        [
          66420
        ]
      ]
    },
    {
      "question_id": "B31",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(SUM(purchased_minor), 0) AS gross_cad_card_spend FROM card_spend_daily WHERE spend_date = DATE '2026-07-01' AND currency = 'CAD'",
      "rows": [
        [
          66420
        ]
      ]
    },
    {
      "question_id": "B32",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(SUM(purchased_minor), 0) AS gross_cad_card_spend_minor FROM card_spend_daily WHERE spend_date = DATE '2026-07-31' AND currency = 'CAD'",
      "rows": [
        [
          38062
        ]
      ]
    },
    {
      "question_id": "B32",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COALESCE(SUM(purchased_minor), 0) FROM card_spend_daily WHERE spend_date = DATE '2026-07-31' AND currency = 'CAD'",
      "rows": [
        [
          38062
        ]
      ]
    },
    {
      "question_id": "B33",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COUNT(*) AS event_count, SUM(amount_minor) AS total_amount_minor FROM transactions WHERE currency = 'CAD' AND event_kind = 'purchase' AND status = 'pending' AND occurred_at >= '2026-07-01' AND occurred_at < '2026-08-01'",
      "rows": [
        [
          31,
          146326
        ]
      ]
    },
    {
      "question_id": "B33",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COUNT(*) AS event_count, SUM(amount_minor) AS total_amount_minor FROM transactions WHERE currency = 'CAD' AND event_kind = 'purchase' AND status = 'pending' AND occurred_at >= '2026-07-01' AND occurred_at < '2026-08-01'",
      "rows": [
        [
          31,
          146326
        ]
      ]
    },
    {
      "question_id": "B34",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COUNT(*) AS event_count, SUM(amount_minor) AS total_amount_minor FROM transactions WHERE currency = 'CAD' AND event_kind = 'purchase' AND status = 'void' AND occurred_at >= '2026-07-01' AND occurred_at < '2026-08-01'",
      "rows": [
        [
          25,
          145470
        ]
      ]
    },
    {
      "question_id": "B34",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT COUNT(*) AS event_count, SUM(amount_minor) AS total_amount_minor FROM transactions WHERE currency = 'CAD' AND event_kind = 'purchase' AND status = 'void' AND EXTRACT(YEAR FROM occurred_at) = 2026 AND EXTRACT(MONTH FROM occurred_at) = 7",
      "rows": [
        [
          25,
          145470
        ]
      ]
    },
    {
      "question_id": "B35",
      "arm": "bare",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT a.account_id\nFROM accounts a\nWHERE a.currency = 'CAD'\nAND NOT EXISTS (\n    SELECT 1\n    FROM card_spend_daily csd\n    WHERE csd.account_id = a.account_id\n    AND csd.spend_date >= DATE '2026-07-01'\n    AND csd.spend_date < DATE '2026-08-01'\n    AND csd.purchased_minor > 0\n)",
      "rows": [
        [
          "acct_019"
        ],
        [
          "acct_017"
        ]
      ]
    },
    {
      "question_id": "B35",
      "arm": "documented",
      "kind": "analytical",
      "correct": false,
      "status": "wrong_answer",
      "sql": "SELECT a.account_id\nFROM accounts a\nLEFT JOIN cards c ON a.account_id = c.account_id\nLEFT JOIN card_spend_daily csd ON c.card_id = csd.card_id AND csd.spend_date >= DATE '2026-07-01' AND csd.spend_date < DATE '2026-08-01' AND csd.purchased_minor > 0\nWHERE a.currency = 'CAD' AND csd.card_id IS NULL",
      "rows": [
        [
          "acct_017"
        ],
        [
          "acct_019"
        ],
        [
          "acct_017"
        ]
      ]
    },
    {
      "question_id": "B36",
      "arm": "documented",
      "kind": "analytical",
      "correct": true,
      "status": "correct",
      "sql": "SELECT currency,\n       SUM(opening_balance_minor) AS opening_balance,\n       SUM(COALESCE(posted_credit_minor, 0) - COALESCE(posted_debit_minor, 0)) AS total_signed_posted_movement,\n       SUM(closing_minor) AS closing_balance\nFROM (\n    SELECT account_id, currency, opening_balance_minor, 0 AS posted_credit_minor, 0 AS posted_debit_minor, 0 AS closing_minor\n    FROM accounts\n    UNION ALL\n    SELECT account_id, currency, 0, posted_credit_minor, posted_debit_minor, 0\n    FROM account_daily\n    WHERE balance_date >= '2026-07-01' AND balance_date <= '2026-07-31'\n    UNION ALL\n    SELECT account_id, currency, 0, 0, 0, closing_minor\n    FROM account_daily\n    WHERE balance_date = '2026-07-31'\n) AS combined\nGROUP BY currency",
      "rows": [
        [
          "CAD",
          646156,
          -520480,
          125676
        ],
        [
          "USD",
          258815,
          -238702,
          20113
        ]
      ]
    },
    {
      "question_id": "B36",
      "arm": "bare",
      "kind": "analytical",
      "correct": false,
      "status": "wrong_answer",
      "sql": "SELECT currency, SUM(opening_minor) AS opening_balance, SUM(posted_credit_minor - posted_debit_minor) AS total_signed_posted_movement, SUM(closing_minor) AS closing_balance FROM account_daily WHERE balance_date BETWEEN DATE '2026-07-01' AND DATE '2026-07-31' GROUP BY currency ORDER BY currency",
      "rows": [
        [
          "CAD",
          15227999,
          -520480,
          14707519
        ],
        [
          "USD",
          5686561,
          -238702,
          5447859
        ]
      ]
    },
    {
      "question_id": "B37",
      "arm": "bare",
      "kind": "clarification",
      "correct": false,
      "status": "unsupported_answer",
      "sql": "SELECT SUM(net_spend_minor) AS total_net_card_spend FROM card_spend_daily WHERE spend_date >= '2026-07-01' AND spend_date < '2026-08-01'",
      "rows": null
    },
    {
      "question_id": "B37",
      "arm": "documented",
      "kind": "clarification",
      "correct": false,
      "status": "unsupported_answer",
      "sql": "SELECT SUM(net_spend_minor) AS total_net_card_spend FROM card_spend_daily WHERE spend_date >= DATE '2026-07-01' AND spend_date < DATE '2026-08-01'",
      "rows": null
    },
    {
      "question_id": "B38",
      "arm": "documented",
      "kind": "clarification",
      "correct": false,
      "status": "unsupported_answer",
      "sql": "SELECT SUM(net_spend_minor) AS net_card_spend_cad FROM card_spend_daily WHERE currency = 'CAD'",
      "rows": null
    },
    {
      "question_id": "B38",
      "arm": "bare",
      "kind": "clarification",
      "correct": false,
      "status": "unsupported_answer",
      "sql": "SELECT SUM(net_spend_minor) AS net_card_spend_cad FROM card_spend_daily WHERE currency = 'CAD'",
      "rows": null
    },
    {
      "question_id": "B39",
      "arm": "bare",
      "kind": "clarification",
      "correct": false,
      "status": "unsupported_answer",
      "sql": "SELECT SUM(closing_minor) AS combined_balance FROM account_daily WHERE balance_date = DATE '2026-07-31' AND currency = 'CAD'",
      "rows": null
    },
    {
      "question_id": "B39",
      "arm": "documented",
      "kind": "clarification",
      "correct": false,
      "status": "unsupported_answer",
      "sql": "SELECT SUM(closing_minor) AS total_balance_minor FROM account_daily WHERE balance_date = DATE '2026-07-31' AND currency = 'CAD'",
      "rows": null
    },
    {
      "question_id": "B40",
      "arm": "documented",
      "kind": "clarification",
      "correct": false,
      "status": "invalid_response",
      "sql": null,
      "rows": null
    },
    {
      "question_id": "B40",
      "arm": "bare",
      "kind": "clarification",
      "correct": false,
      "status": "wrong_clarification",
      "sql": null,
      "rows": null,
      "missing": [
        "balance_definition",
        "metric_definition"
      ]
    }
  ]
}
