Back to practice

Select customer names

Difficulty: Easy

SQL

Try your first run

No account is needed to try this exercise. Write your answer, run the tests, and use the feedback to improve it.

  1. Read the supplied table schema and expected output columns.
  2. Write one read-only query in the editor, then select Run code.
  3. Compare the result tables. Use Hints if you are unsure what to try next.

Sign in to save items for review and keep private notes.

Select every customer name in ascending customer id order. Preserve repeated names.

Return columns name. 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

idcustomer_idamount_centsstatusordered_on
111200paid2026-01-02
21800refunded2026-01-03
321200paid2026-02-01
4990pending2026-02-02

returns

idorder_idamount_cents
11200
21100
32800

customers

idnamecityemail
1AdaAustina@example.test
2BoDallasNULL
3CyAustina@example.test

Each test uses a fresh database. Column names must match the requested aliases.

What this exercise practices

Choose output columns without changing the number of source records. This is the foundation for reasoning about repeated names and the meaning of one SQL result row.

Common mistakes and boundary checks

  • Repeated names belong to separate customer records; DISTINCT would remove required output.
  • Order by customer id even though id is not part of the requested output.
  • An empty table should produce zero rows with the requested column name.

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 contracts
SQL

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.

Reset your code?

This replaces your current code with the starter and stops any running tests.