SQL Data Analytics • Lesson 4

Filtering Data with WHERE

Learn how to filter database rows using WHERE, comparison operators, AND, OR, IN and BETWEEN.

Your progress0%

0 of 8 concepts completed

Complete the activity and related MCQ to unlock the next concept.

Concept 1WHERE

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.

5
CUSTOMERS
3
CITIES
3
STATES
customer_idnamecitystateage
101RahulDelhiDelhi24
102PriyaMumbaiMaharashtra29
103AmitPuneMaharashtra31
104NehaDelhiDelhi26
105ArjunMumbaiMaharashtra34

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

RahulPriyaAmitNehaArjun

WHERE city = Delhi

RahulNeha

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.

01

Understand

What rows does the business need?

02

Condition

What rule identifies those rows?

03

Combine

Are multiple conditions required?

04

Validate

Do the returned rows answer the question?

Lesson Summary

What you learned

WHERE

Filter rows using a condition.

Comparison Operators

Compare values using operators such as >, <, >= and <=.

AND / OR

Combine conditions to express business rules.

IN / BETWEEN

Match a list of values or filter a value range.