SQL Data Analytics • Lesson 4
Filtering Data with WHERE
Learn how to filter database rows using WHERE, comparison operators, AND, OR, IN and BETWEEN.
0 of 8 concepts completed
Complete the activity and related MCQ to unlock the next concept.
Filter Rows with WHERE
WHERE tells SQL which rows should be included in the result. Instead of returning every customer, you can ask SQL to return only rows that satisfy a condition.
Interactive Data
Customers table
Use this customer dataset throughout the lesson to understand how WHERE conditions change the result.
| customer_id | name | city | state | age |
|---|---|---|---|---|
| 101 | Rahul | Delhi | Delhi | 24 |
| 102 | Priya | Mumbai | Maharashtra | 29 |
| 103 | Amit | Pune | Maharashtra | 31 |
| 104 | Neha | Delhi | Delhi | 26 |
| 105 | Arjun | Mumbai | Maharashtra | 34 |
Learn by Seeing
Filter the customer table
SELECT name, city FROM Customers WHERE city = 'Delhi';
The query checks every customer row and keeps only the rows where city equals Delhi.
All customers
WHERE city = Delhi
Interactive Activity
Choose the customers that remain after filtering city = Delhi.
Hint: Look at the city column and keep only rows where the value is exactly Delhi.
Frequently Asked Questions
SQL Filtering FAQs
Open a question to review the key ideas from this lesson.
SQL Analyst Mindset
Think about the rows before writing the condition
SQL filtering is not only about memorizing operators. First understand which rows the business wants, then translate that requirement into precise conditions.
Understand
What rows does the business need?
Condition
What rule identifies those rows?
Combine
Are multiple conditions required?
Validate
Do the returned rows answer the question?
Lesson Summary
What you learned
Filter rows using a condition.
Compare values using operators such as >, <, >= and <=.
Combine conditions to express business rules.
Match a list of values or filter a value range.