TryBench
Data Analysis & SQL · Foundation lesson 2 of 19

Filtering Rows with WHERE

Use WHERE clauses to isolate specific records and exclude irrelevant or cancelled data.

Why this matters

Real tables hold thousands of rows. WHERE lets you pick only the rows that matter, such as finished orders.

Filter Rows With WHERE

WHERE keeps only the rows that match your condition. Text values go inside single quotes.

In real life: WHERE is a filter. A row stays only if it passes the test you write. Text goes inside single quotes, like 'COMPLETED'.

Spelling and Capitals Matter

In SQLite, text matching is case-sensitive. So status = 'COMPLETED' must match the capital letters stored in the table.

In real life: Spelling and capital letters matter. 'COMPLETED' and 'completed' are different to SQLite, so copy the exact value you see in the table.

SELECT order_id, amount
FROM orders
WHERE status = 'COMPLETED';

Your practice task

Finance needs to inspect fulfilled transactions. Retrieve order_id, amount, and status from the orders table for orders where status is 'COMPLETED'.

How to do it

  1. Open THE DATA panel and look at the status column.
  2. Decide which rows Finance needs.
  3. Add a filter so only those rows come back.
  4. Press Run proof and read the checklist.

Practice it for free in the app. You get instant checks that show what you got right and what to fix. A lesson takes about two minutes and you can try as many times as you like.

Quick reference: WHERE Filter Syntax

Isolates matching records based on exact conditions.

SELECT col1, col2
FROM table
WHERE status = 'VALUE';

Practice this lesson free

More lessons in this course

See all 19 lessons in Data Analysis & SQL