SQL · Pattern 2 — Filtering Data
WHERE
WHERE filters rows before grouping or sorting happens — it runs on raw table rows, one at a time, and only lets through the ones that match the condition.
Source data — Pattern 2: Filtering Data
All queries run against the shared employees table (see schema.sql). This pattern also needs the manager_id column for topic 14 — not required back in Pattern 1. It also needs one row with salary < 50000 for topic 9, which Pattern 1's 6 rows didn't have — add:
INSERT INTO employees (employee_id, first_name, last_name, salary, department_id,
manager_id)
VALUES (7, 'Zoya', 'Khan', 42000, 500, 1);

What it does
WHERE filters rows before grouping or sorting happens — it runs on raw table rows, one at a time, and only lets through the ones that match the condition. It's the single most-used clause after SELECT/FROM.
Problem
Find employees earning more than ₹60,000.
SELECT *
FROM employees
WHERE salary > 60000;
Result
