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
- Open THE DATA panel and look at the status column.
- Decide which rows Finance needs.
- Add a filter so only those rows come back.
- 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';
More lessons in this course
- Sorting & Capping with LIMITOrder query results and cap row counts to find top transactions quickly.
- Aggregating Totals with COUNT & SUMCalculate high-level summary metrics across thousands of rows in a single query.
- SQL INNER JOIN Explained for BeginnersCombine data from multiple tables using shared primary and foreign key IDs.