2.2 — Number & Range Filters
What You'll Learn
- How to filter data by number values and ranges in SQL
- Using
BETWEEN
,IN
, and multiple conditions
Filtering Numbers
Excel:
Filter the "Amount" column to show only values greater than 100.
SQL:
sql
SELECT * FROM sales
WHERE Amount > 100;
Filtering a Range of Values
Excel:
Filter "Amount" to show values between 80 and 120.
SQL:
sql
SELECT * FROM sales
WHERE Amount BETWEEN 80 AND 120;
BETWEEN
includes both endpoints (80 and 120).
Filtering Multiple Values
Excel:
Select multiple products in a filter.
SQL:
sql
SELECT * FROM sales
WHERE Product IN ('Apples', 'Oranges');
IN
lets you match any value in the list.
Combining Conditions
Show sales for "Apples" with amount over 100:
sql
SELECT * FROM sales
WHERE Product = 'Apples' AND Amount > 100;
Key Points
- Use
BETWEEN
for ranges,IN
for lists. - Combine conditions with
AND
/OR
for more control.
Next Steps
Next, you'll learn how to filter text using patterns—just like Excel's "contains" filter.