[
 {
  "id": "t1",
  "title": "Task 1: one fan-out (orders and line items)",
  "key": "name",
  "columns": [
   "revenue",
   "units"
  ],
  "expected": {
   "Asha": [
    200,
    5
   ],
   "Ben": [
    200,
    4
   ],
   "Chen": [
    50,
    2
   ]
  },
  "schema": "CREATE TABLE customers (\n  id INTEGER PRIMARY KEY,\n  name TEXT NOT NULL\n);\n\nCREATE TABLE orders (\n  id INTEGER PRIMARY KEY,\n  customer_id INTEGER NOT NULL REFERENCES customers(id),\n  order_total INTEGER NOT NULL      -- amount charged for the whole order, in dollars\n);\n\nCREATE TABLE order_items (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order has one or more lines\n  qty INTEGER NOT NULL,             -- units on this line\n  line_amount INTEGER NOT NULL      -- dollars for this line\n);\n",
  "seed": "INSERT INTO customers VALUES (1,'Asha'),(2,'Ben'),(3,'Chen');\nINSERT INTO orders VALUES (101,1,120),(102,1,80),(103,2,200),(104,3,50);\nINSERT INTO order_items VALUES\n  (1,101,1,40),(2,101,1,40),(3,101,1,40),\n  (4,102,1,50),(5,102,1,30),\n  (6,103,1,50),(7,103,1,50),(8,103,1,50),(9,103,1,50),\n  (10,104,2,50);\n",
  "variant": "UPDATE order_items SET qty = 1, line_amount = 25 WHERE id = 10;\nINSERT INTO order_items VALUES (11, 104, 1, 25);\n",
  "prompts": {
   "bare": "SQLite schema:\n\nCREATE TABLE customers (\n  id INTEGER PRIMARY KEY,\n  name TEXT NOT NULL\n);\n\nCREATE TABLE orders (\n  id INTEGER PRIMARY KEY,\n  customer_id INTEGER NOT NULL REFERENCES customers(id),\n  order_total INTEGER NOT NULL\n);\n\nCREATE TABLE order_items (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),\n  qty INTEGER NOT NULL,\n  line_amount INTEGER NOT NULL\n);\n\nWrite one SQLite query that returns one row per customer with exactly these columns: name, revenue, units.\nrevenue is the total amount charged to the customer. units is the total number of units the customer bought.\n\nReply with only the query, in a single ```sql code block.\n",
   "documented": "SQLite schema:\n\nCREATE TABLE customers (\n  id INTEGER PRIMARY KEY,\n  name TEXT NOT NULL\n);\n\nCREATE TABLE orders (\n  id INTEGER PRIMARY KEY,\n  customer_id INTEGER NOT NULL REFERENCES customers(id),\n  order_total INTEGER NOT NULL      -- amount charged for the whole order, in dollars\n);\n\nCREATE TABLE order_items (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order has one or more lines\n  qty INTEGER NOT NULL,             -- units on this line\n  line_amount INTEGER NOT NULL      -- dollars for this line\n);\n\nWrite one SQLite query that returns one row per customer with exactly these columns: name, revenue, units.\nrevenue is the total amount charged to the customer. units is the total number of units the customer bought.\n\nReply with only the query, in a single ```sql code block.\n"
  }
 },
 {
  "id": "t2",
  "title": "Task 2: two fan-outs plus an order with no payments",
  "key": "name",
  "columns": [
   "charged",
   "paid",
   "units"
  ],
  "expected": {
   "Asha": [
    200,
    120,
    5
   ],
   "Ben": [
    200,
    200,
    4
   ],
   "Chen": [
    50,
    50,
    2
   ]
  },
  "schema": "CREATE TABLE customers (\n  id INTEGER PRIMARY KEY,\n  name TEXT NOT NULL\n);\n\nCREATE TABLE orders (\n  id INTEGER PRIMARY KEY,\n  customer_id INTEGER NOT NULL REFERENCES customers(id),\n  order_total INTEGER NOT NULL      -- amount charged for the whole order, in dollars\n);\n\nCREATE TABLE order_items (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order has one or more lines\n  qty INTEGER NOT NULL,             -- units on this line\n  line_amount INTEGER NOT NULL      -- dollars for this line\n);\n\nCREATE TABLE payments (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order can have zero, one or many payments\n  amount INTEGER NOT NULL           -- dollars received in this payment\n);\n",
  "seed": "INSERT INTO customers VALUES (1,'Asha'),(2,'Ben'),(3,'Chen');\nINSERT INTO orders VALUES (101,1,120),(102,1,80),(103,2,200),(104,3,50);\nINSERT INTO order_items VALUES\n  (1,101,1,40),(2,101,1,40),(3,101,1,40),\n  (4,102,1,50),(5,102,1,30),\n  (6,103,1,50),(7,103,1,50),(8,103,1,50),(9,103,1,50),\n  (10,104,2,50);\nINSERT INTO payments VALUES (1,101,60),(2,101,60),(3,103,100),(4,103,50),(5,103,50),(6,104,50);\n",
  "variant": "UPDATE order_items SET qty = 1, line_amount = 25 WHERE id = 10;\nINSERT INTO order_items VALUES (11, 104, 1, 25);\nUPDATE payments SET amount = 25 WHERE id = 6;\nINSERT INTO payments VALUES (7, 104, 25);\n",
  "prompts": {
   "bare": "SQLite schema:\n\nCREATE TABLE customers (\n  id INTEGER PRIMARY KEY,\n  name TEXT NOT NULL\n);\n\nCREATE TABLE orders (\n  id INTEGER PRIMARY KEY,\n  customer_id INTEGER NOT NULL REFERENCES customers(id),\n  order_total INTEGER NOT NULL\n);\n\nCREATE TABLE order_items (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),\n  qty INTEGER NOT NULL,\n  line_amount INTEGER NOT NULL\n);\n\nCREATE TABLE payments (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),\n  amount INTEGER NOT NULL\n);\n\nWrite one SQLite query that returns one row per customer with exactly these columns: name, charged, paid, units.\ncharged is the total amount charged to the customer across all their orders. paid is the total of payments received from the customer. units is the total number of units the customer bought.\n\nReply with only the query, in a single ```sql code block.\n",
   "documented": "SQLite schema:\n\nCREATE TABLE customers (\n  id INTEGER PRIMARY KEY,\n  name TEXT NOT NULL\n);\n\nCREATE TABLE orders (\n  id INTEGER PRIMARY KEY,\n  customer_id INTEGER NOT NULL REFERENCES customers(id),\n  order_total INTEGER NOT NULL      -- amount charged for the whole order, in dollars\n);\n\nCREATE TABLE order_items (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order has one or more lines\n  qty INTEGER NOT NULL,             -- units on this line\n  line_amount INTEGER NOT NULL      -- dollars for this line\n);\n\nCREATE TABLE payments (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order can have zero, one or many payments\n  amount INTEGER NOT NULL           -- dollars received in this payment\n);\n\nWrite one SQLite query that returns one row per customer with exactly these columns: name, charged, paid, units.\ncharged is the total amount charged to the customer across all their orders. paid is the total of payments received from the customer. units is the total number of units the customer bought.\n\nReply with only the query, in a single ```sql code block.\n",
   "keyless": "SQLite schema:\n\nCREATE TABLE customers (\n  id INTEGER,\n  name TEXT\n);\n\nCREATE TABLE orders (\n  id INTEGER,\n  customer_id INTEGER,\n  order_total INTEGER\n);\n\nCREATE TABLE order_items (\n  id INTEGER,\n  order_id INTEGER,\n  qty INTEGER,\n  line_amount INTEGER\n);\n\nCREATE TABLE payments (\n  id INTEGER,\n  order_id INTEGER,\n  amount INTEGER\n);\n\nWrite one SQLite query that returns one row per customer with exactly these columns: name, charged, paid, units.\ncharged is the total amount charged to the customer across all their orders. paid is the total of payments received from the customer. units is the total number of units the customer bought.\n\nReply with only the query, in a single ```sql code block.\n"
  }
 },
 {
  "id": "t3",
  "title": "Task 3: summary table joined to a history table and a lookup",
  "key": "region",
  "columns": [
   "total_debt",
   "total_repaid",
   "target_repayment_ratio"
  ],
  "expected": {
   "North": [
    400,
    130,
    0.25
   ],
   "South": [
    250,
    65,
    0.4
   ]
  },
  "schema": "CREATE TABLE region_benchmarks (\n  region TEXT PRIMARY KEY,                 -- one row per region\n  target_repayment_ratio REAL NOT NULL\n);\n\nCREATE TABLE country_debt_summary (\n  country TEXT PRIMARY KEY,                -- one row per country\n  region TEXT NOT NULL REFERENCES region_benchmarks(region),\n  outstanding_debt INTEGER NOT NULL        -- total outstanding debt for the country, USD millions\n);\n\nCREATE TABLE repayments (\n  id INTEGER PRIMARY KEY,\n  country TEXT NOT NULL REFERENCES country_debt_summary(country),  -- a country has many repayments\n  paid_on TEXT NOT NULL,                   -- date of the repayment\n  amount INTEGER NOT NULL                  -- USD millions\n);\n",
  "seed": "INSERT INTO region_benchmarks VALUES ('North',0.25),('South',0.40);\nINSERT INTO country_debt_summary VALUES ('A','North',100),('B','North',300),('C','South',200),('D','South',50);\nINSERT INTO repayments VALUES\n  (1,'A','2024-03-31',10),(2,'A','2024-09-30',10),(3,'A','2025-03-31',10),\n  (4,'B','2023-06-30',20),(5,'B','2023-12-31',20),(6,'B','2024-06-30',20),(7,'B','2024-12-31',20),(8,'B','2025-06-30',20),\n  (9,'C','2024-06-30',30),(10,'C','2025-06-30',30),\n  (11,'D','2025-06-30',5);\n",
  "variant": "UPDATE repayments SET amount = 10 WHERE id = 4;\nINSERT INTO repayments VALUES (12,'B','2023-06-30',10);\n",
  "prompts": {
   "bare": "SQLite schema:\n\nCREATE TABLE region_benchmarks (\n  region TEXT PRIMARY KEY,\n  target_repayment_ratio REAL NOT NULL\n);\n\nCREATE TABLE country_debt_summary (\n  country TEXT PRIMARY KEY,\n  region TEXT NOT NULL REFERENCES region_benchmarks(region),\n  outstanding_debt INTEGER NOT NULL\n);\n\nCREATE TABLE repayments (\n  id INTEGER PRIMARY KEY,\n  country TEXT NOT NULL REFERENCES country_debt_summary(country),\n  paid_on TEXT NOT NULL,\n  amount INTEGER NOT NULL\n);\n\nWrite one SQLite query that returns one row per region with exactly these columns: region, total_debt, total_repaid, target_repayment_ratio.\ntotal_debt is the sum of outstanding debt for the countries in the region. total_repaid is the sum of all repayments made by those countries.\n\nReply with only the query, in a single ```sql code block.\n",
   "documented": "SQLite schema:\n\nCREATE TABLE region_benchmarks (\n  region TEXT PRIMARY KEY,                 -- one row per region\n  target_repayment_ratio REAL NOT NULL\n);\n\nCREATE TABLE country_debt_summary (\n  country TEXT PRIMARY KEY,                -- one row per country\n  region TEXT NOT NULL REFERENCES region_benchmarks(region),\n  outstanding_debt INTEGER NOT NULL        -- total outstanding debt for the country, USD millions\n);\n\nCREATE TABLE repayments (\n  id INTEGER PRIMARY KEY,\n  country TEXT NOT NULL REFERENCES country_debt_summary(country),  -- a country has many repayments\n  paid_on TEXT NOT NULL,                   -- date of the repayment\n  amount INTEGER NOT NULL                  -- USD millions\n);\n\nWrite one SQLite query that returns one row per region with exactly these columns: region, total_debt, total_repaid, target_repayment_ratio.\ntotal_debt is the sum of outstanding debt for the countries in the region. total_repaid is the sum of all repayments made by those countries.\n\nReply with only the query, in a single ```sql code block.\n"
  }
 },
 {
  "id": "t4",
  "title": "Task 4: wide report with a count and an average",
  "key": "name",
  "columns": [
   "orders",
   "charged",
   "avg_order",
   "paid",
   "units"
  ],
  "expected": {
   "Asha": [
    2,
    200,
    100,
    120,
    5
   ],
   "Ben": [
    1,
    200,
    200,
    200,
    4
   ],
   "Chen": [
    1,
    50,
    50,
    50,
    2
   ]
  },
  "schema": "CREATE TABLE customers (\n  id INTEGER PRIMARY KEY,\n  name TEXT NOT NULL\n);\n\nCREATE TABLE orders (\n  id INTEGER PRIMARY KEY,\n  customer_id INTEGER NOT NULL REFERENCES customers(id),\n  order_total INTEGER NOT NULL      -- amount charged for the whole order, in dollars\n);\n\nCREATE TABLE order_items (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order has one or more lines\n  qty INTEGER NOT NULL,             -- units on this line\n  line_amount INTEGER NOT NULL      -- dollars for this line\n);\n\nCREATE TABLE payments (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order can have zero, one or many payments\n  amount INTEGER NOT NULL           -- dollars received in this payment\n);\n",
  "seed": "INSERT INTO customers VALUES (1,'Asha'),(2,'Ben'),(3,'Chen');\nINSERT INTO orders VALUES (101,1,120),(102,1,80),(103,2,200),(104,3,50);\nINSERT INTO order_items VALUES\n  (1,101,1,40),(2,101,1,40),(3,101,1,40),\n  (4,102,1,50),(5,102,1,30),\n  (6,103,1,50),(7,103,1,50),(8,103,1,50),(9,103,1,50),\n  (10,104,2,50);\nINSERT INTO payments VALUES (1,101,60),(2,101,60),(3,103,100),(4,103,50),(5,103,50),(6,104,50);\n",
  "variant": "UPDATE order_items SET qty = 1, line_amount = 25 WHERE id = 10;\nINSERT INTO order_items VALUES (11, 104, 1, 25);\nUPDATE payments SET amount = 25 WHERE id = 6;\nINSERT INTO payments VALUES (7, 104, 25);\n",
  "prompts": {
   "bare": "SQLite schema:\n\nCREATE TABLE customers (\n  id INTEGER PRIMARY KEY,\n  name TEXT NOT NULL\n);\n\nCREATE TABLE orders (\n  id INTEGER PRIMARY KEY,\n  customer_id INTEGER NOT NULL REFERENCES customers(id),\n  order_total INTEGER NOT NULL\n);\n\nCREATE TABLE order_items (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),\n  qty INTEGER NOT NULL,\n  line_amount INTEGER NOT NULL\n);\n\nCREATE TABLE payments (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),\n  amount INTEGER NOT NULL\n);\n\nWrite one SQLite query that returns one row per customer with exactly these columns: name, orders, charged, avg_order, paid, units.\norders is the number of orders the customer placed. charged is the total amount charged to the customer across all their orders. avg_order is the average amount charged per order. paid is the total of payments received from the customer. units is the total number of units the customer bought.\n\nReply with only the query, in a single ```sql code block.\n",
   "documented": "SQLite schema:\n\nCREATE TABLE customers (\n  id INTEGER PRIMARY KEY,\n  name TEXT NOT NULL\n);\n\nCREATE TABLE orders (\n  id INTEGER PRIMARY KEY,\n  customer_id INTEGER NOT NULL REFERENCES customers(id),\n  order_total INTEGER NOT NULL      -- amount charged for the whole order, in dollars\n);\n\nCREATE TABLE order_items (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order has one or more lines\n  qty INTEGER NOT NULL,             -- units on this line\n  line_amount INTEGER NOT NULL      -- dollars for this line\n);\n\nCREATE TABLE payments (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order can have zero, one or many payments\n  amount INTEGER NOT NULL           -- dollars received in this payment\n);\n\nWrite one SQLite query that returns one row per customer with exactly these columns: name, orders, charged, avg_order, paid, units.\norders is the number of orders the customer placed. charged is the total amount charged to the customer across all their orders. avg_order is the average amount charged per order. paid is the total of payments received from the customer. units is the total number of units the customer bought.\n\nReply with only the query, in a single ```sql code block.\n",
   "keyless": "SQLite schema:\n\nCREATE TABLE customers (\n  id INTEGER,\n  name TEXT\n);\n\nCREATE TABLE orders (\n  id INTEGER,\n  customer_id INTEGER,\n  order_total INTEGER\n);\n\nCREATE TABLE order_items (\n  id INTEGER,\n  order_id INTEGER,\n  qty INTEGER,\n  line_amount INTEGER\n);\n\nCREATE TABLE payments (\n  id INTEGER,\n  order_id INTEGER,\n  amount INTEGER\n);\n\nWrite one SQLite query that returns one row per customer with exactly these columns: name, orders, charged, avg_order, paid, units.\norders is the number of orders the customer placed. charged is the total amount charged to the customer across all their orders. avg_order is the average amount charged per order. paid is the total of payments received from the customer. units is the total number of units the customer bought.\n\nReply with only the query, in a single ```sql code block.\n"
  }
 },
 {
  "id": "t5",
  "title": "Task 5: a country total repeated on every detail row",
  "key": "region",
  "columns": [
   "total_debt",
   "countries",
   "target_repayment_ratio"
  ],
  "expected": {
   "North": [
    400,
    2,
    0.25
   ],
   "South": [
    250,
    2,
    0.4
   ]
  },
  "schema": "CREATE TABLE region_benchmarks (\n  region TEXT PRIMARY KEY,                 -- one row per region\n  target_repayment_ratio REAL NOT NULL\n);\n\nCREATE TABLE debt_positions (\n  country TEXT NOT NULL,\n  region TEXT NOT NULL REFERENCES region_benchmarks(region),\n  creditor_type TEXT NOT NULL,             -- one row per country and creditor type\n  outstanding_amount INTEGER NOT NULL,     -- debt owed to this creditor type, USD millions\n  country_total_debt INTEGER NOT NULL,     -- the country's total across all creditor types, repeated on each of its rows\n  PRIMARY KEY (country, creditor_type)\n);\n",
  "seed": "INSERT INTO region_benchmarks VALUES ('North',0.25),('South',0.40);\nINSERT INTO debt_positions VALUES\n  ('A','North','bilateral',40,100),('A','North','multilateral',60,100),\n  ('B','North','bilateral',100,300),('B','North','multilateral',120,300),('B','North','private',80,300),\n  ('C','South','bilateral',150,200),('C','South','multilateral',50,200),\n  ('D','South','multilateral',50,50);\n",
  "variant": "UPDATE debt_positions SET outstanding_amount = 40 WHERE country = 'B' AND creditor_type = 'private';\nINSERT INTO debt_positions VALUES ('B','North','bond',40,300);\n",
  "prompts": {
   "bare": "SQLite schema:\n\nCREATE TABLE region_benchmarks (\n  region TEXT PRIMARY KEY,\n  target_repayment_ratio REAL NOT NULL\n);\n\nCREATE TABLE debt_positions (\n  country TEXT NOT NULL,\n  region TEXT NOT NULL REFERENCES region_benchmarks(region),\n  creditor_type TEXT NOT NULL,\n  outstanding_amount INTEGER NOT NULL,\n  country_total_debt INTEGER NOT NULL,\n  PRIMARY KEY (country, creditor_type)\n);\n\nWrite one SQLite query that returns one row per region with exactly these columns: region, total_debt, countries, target_repayment_ratio.\ntotal_debt is the total outstanding debt of the countries in the region. countries is the number of countries in the region.\n\nReply with only the query, in a single ```sql code block.\n",
   "documented": "SQLite schema:\n\nCREATE TABLE region_benchmarks (\n  region TEXT PRIMARY KEY,                 -- one row per region\n  target_repayment_ratio REAL NOT NULL\n);\n\nCREATE TABLE debt_positions (\n  country TEXT NOT NULL,\n  region TEXT NOT NULL REFERENCES region_benchmarks(region),\n  creditor_type TEXT NOT NULL,             -- one row per country and creditor type\n  outstanding_amount INTEGER NOT NULL,     -- debt owed to this creditor type, USD millions\n  country_total_debt INTEGER NOT NULL,     -- the country's total across all creditor types, repeated on each of its rows\n  PRIMARY KEY (country, creditor_type)\n);\n\nWrite one SQLite query that returns one row per region with exactly these columns: region, total_debt, countries, target_repayment_ratio.\ntotal_debt is the total outstanding debt of the countries in the region. countries is the number of countries in the region.\n\nReply with only the query, in a single ```sql code block.\n",
   "keyless": "SQLite schema:\n\nCREATE TABLE region_benchmarks (\n  region TEXT,\n  target_repayment_ratio REAL\n);\n\nCREATE TABLE debt_positions (\n  country TEXT,\n  region TEXT,\n  creditor_type TEXT,\n  outstanding_amount INTEGER,\n  country_total_debt INTEGER\n);\n\nWrite one SQLite query that returns one row per region with exactly these columns: region, total_debt, countries, target_repayment_ratio.\ntotal_debt is the total outstanding debt of the countries in the region. countries is the number of countries in the region.\n\nReply with only the query, in a single ```sql code block.\n"
  }
 },
 {
  "id": "t6",
  "title": "Task 6: nine tables, four child tables, seven metrics",
  "key": "name",
  "columns": [
   "orders",
   "charged",
   "refunded",
   "net_revenue",
   "paid",
   "units",
   "shipments"
  ],
  "expected": {
   "Asha": [
    2,
    200,
    20,
    180,
    120,
    5,
    2
   ],
   "Ben": [
    1,
    200,
    25,
    175,
    200,
    4,
    1
   ],
   "Chen": [
    1,
    50,
    0,
    50,
    50,
    2,
    1
   ]
  },
  "schema": "CREATE TABLE segments (\n  id INTEGER PRIMARY KEY,\n  label TEXT NOT NULL\n);\n\nCREATE TABLE customers (\n  id INTEGER PRIMARY KEY,\n  name TEXT NOT NULL,\n  segment_id INTEGER REFERENCES segments(id)\n);\n\nCREATE TABLE products (\n  id INTEGER PRIMARY KEY,\n  sku TEXT NOT NULL,\n  category TEXT NOT NULL\n);\n\nCREATE TABLE orders (\n  id INTEGER PRIMARY KEY,\n  customer_id INTEGER NOT NULL REFERENCES customers(id),\n  placed_on TEXT NOT NULL,\n  order_total INTEGER NOT NULL      -- amount charged for the whole order, in dollars\n);\n\nCREATE TABLE order_items (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order has one or more lines\n  product_id INTEGER NOT NULL REFERENCES products(id),\n  qty INTEGER NOT NULL,             -- units on this line\n  line_amount INTEGER NOT NULL      -- dollars for this line\n);\n\nCREATE TABLE payments (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order can have zero, one or many payments\n  received_on TEXT NOT NULL,\n  amount INTEGER NOT NULL           -- dollars received in this payment\n);\n\nCREATE TABLE refunds (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order can have zero, one or many refunds\n  issued_on TEXT NOT NULL,\n  amount INTEGER NOT NULL           -- dollars refunded\n);\n\nCREATE TABLE shipments (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order can have zero, one or many shipments\n  shipped_on TEXT NOT NULL,\n  carrier TEXT NOT NULL\n);\n\nCREATE TABLE support_tickets (\n  id INTEGER PRIMARY KEY,\n  customer_id INTEGER NOT NULL REFERENCES customers(id),\n  opened_on TEXT NOT NULL\n);\n",
  "seed": "INSERT INTO segments VALUES (1,'Retail'),(2,'Wholesale');\nINSERT INTO customers VALUES (1,'Asha',1),(2,'Ben',2),(3,'Chen',1);\nINSERT INTO products VALUES (1,'SKU-1','Tools'),(2,'SKU-2','Parts');\nINSERT INTO orders VALUES (101,1,'2026-01-10',120),(102,1,'2026-02-02',80),(103,2,'2026-02-14',200),(104,3,'2026-03-01',50);\nINSERT INTO order_items VALUES\n  (1,101,1,1,40),(2,101,2,1,40),(3,101,1,1,40),\n  (4,102,1,1,50),(5,102,2,1,30),\n  (6,103,1,1,50),(7,103,1,1,50),(8,103,2,1,50),(9,103,2,1,50),\n  (10,104,1,2,50);\nINSERT INTO payments VALUES (1,101,'2026-01-11',60),(2,101,'2026-01-20',60),(3,103,'2026-02-15',100),(4,103,'2026-02-20',50),(5,103,'2026-03-01',50),(6,104,'2026-03-02',50);\nINSERT INTO refunds VALUES (1,101,'2026-01-25',20),(2,103,'2026-02-22',10),(3,103,'2026-03-03',15);\nINSERT INTO shipments VALUES (1,101,'2026-01-12','DHL'),(2,101,'2026-01-14','DHL'),(3,103,'2026-02-16','UPS'),(4,104,'2026-03-03','UPS');\nINSERT INTO support_tickets VALUES (1,1,'2026-01-26'),(2,1,'2026-02-03'),(3,2,'2026-02-23');\n",
  "variant": "UPDATE order_items SET qty = 1, line_amount = 25 WHERE id = 10;\nINSERT INTO order_items VALUES (11, 104, 1, 1, 25);\nUPDATE payments SET amount = 25 WHERE id = 6;\nINSERT INTO payments VALUES (7, 104, '2026-03-02', 25);\nUPDATE refunds SET amount = 5 WHERE id = 2;\nINSERT INTO refunds VALUES (4, 103, '2026-02-22', 5);\n",
  "prompts": {
   "bare": "SQLite schema:\n\nCREATE TABLE segments (\n  id INTEGER PRIMARY KEY,\n  label TEXT NOT NULL\n);\n\nCREATE TABLE customers (\n  id INTEGER PRIMARY KEY,\n  name TEXT NOT NULL,\n  segment_id INTEGER REFERENCES segments(id)\n);\n\nCREATE TABLE products (\n  id INTEGER PRIMARY KEY,\n  sku TEXT NOT NULL,\n  category TEXT NOT NULL\n);\n\nCREATE TABLE orders (\n  id INTEGER PRIMARY KEY,\n  customer_id INTEGER NOT NULL REFERENCES customers(id),\n  placed_on TEXT NOT NULL,\n  order_total INTEGER NOT NULL\n);\n\nCREATE TABLE order_items (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),\n  product_id INTEGER NOT NULL REFERENCES products(id),\n  qty INTEGER NOT NULL,\n  line_amount INTEGER NOT NULL\n);\n\nCREATE TABLE payments (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),\n  received_on TEXT NOT NULL,\n  amount INTEGER NOT NULL\n);\n\nCREATE TABLE refunds (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),\n  issued_on TEXT NOT NULL,\n  amount INTEGER NOT NULL\n);\n\nCREATE TABLE shipments (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),\n  shipped_on TEXT NOT NULL,\n  carrier TEXT NOT NULL\n);\n\nCREATE TABLE support_tickets (\n  id INTEGER PRIMARY KEY,\n  customer_id INTEGER NOT NULL REFERENCES customers(id),\n  opened_on TEXT NOT NULL\n);\n\nWrite one SQLite query that returns one row per customer with exactly these columns: name, orders, charged, refunded, net_revenue, paid, units, shipments.\norders is the number of orders the customer placed. charged is the total amount charged to the customer across all their orders. refunded is the total amount refunded to the customer. net_revenue is charged minus refunded. paid is the total of payments received from the customer. units is the total number of units the customer bought. shipments is the number of shipments sent to the customer.\n\nReply with only the query, in a single ```sql code block.\n",
   "documented": "SQLite schema:\n\nCREATE TABLE segments (\n  id INTEGER PRIMARY KEY,\n  label TEXT NOT NULL\n);\n\nCREATE TABLE customers (\n  id INTEGER PRIMARY KEY,\n  name TEXT NOT NULL,\n  segment_id INTEGER REFERENCES segments(id)\n);\n\nCREATE TABLE products (\n  id INTEGER PRIMARY KEY,\n  sku TEXT NOT NULL,\n  category TEXT NOT NULL\n);\n\nCREATE TABLE orders (\n  id INTEGER PRIMARY KEY,\n  customer_id INTEGER NOT NULL REFERENCES customers(id),\n  placed_on TEXT NOT NULL,\n  order_total INTEGER NOT NULL      -- amount charged for the whole order, in dollars\n);\n\nCREATE TABLE order_items (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order has one or more lines\n  product_id INTEGER NOT NULL REFERENCES products(id),\n  qty INTEGER NOT NULL,             -- units on this line\n  line_amount INTEGER NOT NULL      -- dollars for this line\n);\n\nCREATE TABLE payments (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order can have zero, one or many payments\n  received_on TEXT NOT NULL,\n  amount INTEGER NOT NULL           -- dollars received in this payment\n);\n\nCREATE TABLE refunds (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order can have zero, one or many refunds\n  issued_on TEXT NOT NULL,\n  amount INTEGER NOT NULL           -- dollars refunded\n);\n\nCREATE TABLE shipments (\n  id INTEGER PRIMARY KEY,\n  order_id INTEGER NOT NULL REFERENCES orders(id),  -- an order can have zero, one or many shipments\n  shipped_on TEXT NOT NULL,\n  carrier TEXT NOT NULL\n);\n\nCREATE TABLE support_tickets (\n  id INTEGER PRIMARY KEY,\n  customer_id INTEGER NOT NULL REFERENCES customers(id),\n  opened_on TEXT NOT NULL\n);\n\nWrite one SQLite query that returns one row per customer with exactly these columns: name, orders, charged, refunded, net_revenue, paid, units, shipments.\norders is the number of orders the customer placed. charged is the total amount charged to the customer across all their orders. refunded is the total amount refunded to the customer. net_revenue is charged minus refunded. paid is the total of payments received from the customer. units is the total number of units the customer bought. shipments is the number of shipments sent to the customer.\n\nReply with only the query, in a single ```sql code block.\n",
   "keyless": "SQLite schema:\n\nCREATE TABLE segments (\n  id INTEGER,\n  label TEXT\n);\n\nCREATE TABLE customers (\n  id INTEGER,\n  name TEXT,\n  segment_id INTEGER\n);\n\nCREATE TABLE products (\n  id INTEGER,\n  sku TEXT,\n  category TEXT\n);\n\nCREATE TABLE orders (\n  id INTEGER,\n  customer_id INTEGER,\n  placed_on TEXT,\n  order_total INTEGER\n);\n\nCREATE TABLE order_items (\n  id INTEGER,\n  order_id INTEGER,\n  product_id INTEGER,\n  qty INTEGER,\n  line_amount INTEGER\n);\n\nCREATE TABLE payments (\n  id INTEGER,\n  order_id INTEGER,\n  received_on TEXT,\n  amount INTEGER\n);\n\nCREATE TABLE refunds (\n  id INTEGER,\n  order_id INTEGER,\n  issued_on TEXT,\n  amount INTEGER\n);\n\nCREATE TABLE shipments (\n  id INTEGER,\n  order_id INTEGER,\n  shipped_on TEXT,\n  carrier TEXT\n);\n\nCREATE TABLE support_tickets (\n  id INTEGER,\n  customer_id INTEGER,\n  opened_on TEXT\n);\n\nWrite one SQLite query that returns one row per customer with exactly these columns: name, orders, charged, refunded, net_revenue, paid, units, shipments.\norders is the number of orders the customer placed. charged is the total amount charged to the customer across all their orders. refunded is the total amount refunded to the customer. net_revenue is charged minus refunded. paid is the total of payments received from the customer. units is the total number of units the customer bought. shipments is the number of shipments sent to the customer.\n\nReply with only the query, in a single ```sql code block.\n"
  }
 }
]
