A fixture is a handful of rows you can answer by hand
The third step is a fixture, and this lesson uses one throughout.
Why does the fixture give Ana two March orders?
Here's the whole fixture. Each customer is shown with their orders, and each order with its item lines and their quantities:
| Customer | Order | placed_at | Cents |
|---|---|---|---|
| 1 Ana, Austin | 10 | 2026-03-02 12:15 | 2500 |
| 11 | 2026-03-02 19:40 | 1800 | |
| 2 Ben, Austin | 12 | 2026-03-15 08:05 | 1800 |
| 3 Cy, Boston | 13 | 2026-03-31 20:30 | 1500 |
| 14 | 2026-04-01 09:00 | 2100 | |
| 4 Dee, Denver | no orders |
| Order | Promo | Item lines |
|---|---|---|
| 10 | NULL | pho 1, spring rolls 2 |
| 11 | FREESHIP | tacos 3 |
| 12 | SPRING | curry 1 |
| 13 | NULL | pho 1 |
| 14 | NULL | ramen 2 |
It's small enough to answer in your head. Every row is there because some kind of bug changes the answer when that row exists:
| Row | Breaks a query that |
|---|---|
| Ana's two orders | counts orders when the question counts customers |
| Order 10's two item lines | sums order totals after joining to items |
| Orders 11 and 12, both 1800 | patches that join with SUM(DISTINCT ...) |
| Dee, with no orders | lets a LEFT JOIN turn inner, or counts its empty row |
| Three NULL promos | compares promo with <> or NOT IN |
| 2 of 5 orders with a promo | divides one integer count by another |
| Order 13 at 20:30 on March 31 | uses BETWEEN with a bare end date |
| Order 14 on April 1 | lets the end of the range in |
The same tables as SQL, with columns customers(customer_id, name, city), orders(order_id, customer_id, placed_at, total_cents, promo) and items(order_id, dish, qty). In Python, sqlite3.connect(":memory:").executescript(fixture) loads them. Every query and result below runs on them in SQLite.
CREATE TABLE customers (customer_id INTEGER, name TEXT, city TEXT);
CREATE TABLE orders (order_id INTEGER, customer_id INTEGER,
placed_at TEXT, total_cents INTEGER, promo TEXT);
CREATE TABLE items (order_id INTEGER, dish TEXT, qty INTEGER);
INSERT INTO customers VALUES
(1, 'Ana', 'Austin'), (2, 'Ben', 'Austin'),
(3, 'Cy', 'Boston'), (4, 'Dee', 'Denver');
INSERT INTO orders VALUES
(10, 1, '2026-03-02 12:15', 2500, NULL),
(11, 1, '2026-03-02 19:40', 1800, 'FREESHIP'),
(12, 2, '2026-03-15 08:05', 1800, 'SPRING'),
(13, 3, '2026-03-31 20:30', 1500, NULL),
(14, 3, '2026-04-01 09:00', 2100, NULL);
INSERT INTO items VALUES
(10, 'pho', 1), (10, 'spring rolls', 2), (11, 'tacos', 3),
(12, 'curry', 1), (13, 'pho', 1), (14, 'ramen', 2);Write the right answers down before you run anything. Run first, and the output quietly becomes your expectation.