Name an output column
Difficulty: Easy
Return each order id and amount_cents renamed cents, ordered by id.
Return columns id, cents. Use the specified ordering; ties must be resolved as described.
Schema and sample data
CREATE TABLE customers (id INTEGER PRIMARY KEY, name TEXT, city TEXT, email TEXT);
CREATE TABLE orders (id INTEGER PRIMARY KEY, customer_id INTEGER, amount_cents INTEGER, status TEXT, ordered_on TEXT);
CREATE TABLE returns (id INTEGER PRIMARY KEY, order_id INTEGER, amount_cents INTEGER);orders
| id | customer_id | amount_cents | status | ordered_on |
|---|---|---|---|---|
| 1 | 1 | 1200 | paid | 2026-01-02 |
| 2 | 1 | 800 | refunded | 2026-01-03 |
| 3 | 2 | 1200 | paid | 2026-02-01 |
| 4 | 99 | 0 | pending | 2026-02-02 |
returns
| id | order_id | amount_cents |
|---|---|---|
| 1 | 1 | 200 |
| 2 | 1 | 100 |
| 3 | 2 | 800 |
customers
| id | name | city | |
|---|---|---|---|
| 1 | Ada | Austin | a@example.test |
| 2 | Bo | Dallas | NULL |
| 3 | Cy | Austin | a@example.test |
Each test uses a fresh database. Column names must match the requested aliases.
Constraints
Use one SQLite SELECT query, optionally with CTEs. No writes, uploads, network, or extension loading. Data is synthetic. Integers are cents; do not use floating-point money. Each test has at most 1,000 rows per table. Medium exercises combine query stages; no database index is assumed.
Review lesson: Tables, rows, and output contractsA little nudge
Reveal one hint at a time. Give yourself a moment to try it.
Worked solution
Try your own approach first, then compare the reasoning.
Complexity
Ready when you are
Write your solution, then run it against the practice tests.
Press Esc, then Tab to leave the editor. Code runs in an isolated browser workspace. Tests support learning, not verified grading.