The NOT IN operator returns rows where a value does not match any value in the specified list.
NOT IN is useful when several categories or values need to be excluded from analysis.
Find employees who are not in IT, Finance, or HR.
SELECT
EmployeeName,
Department
FROM Employees
WHERE Department NOT IN ('IT', 'Finance', 'HR');
Analysts use NOT IN for exclusion reporting, category filtering, exception analysis, and data-quality checks.
- NOT IN excludes listed values.
- It can replace multiple <> conditions.
- It is useful for exclusion logic.
- NULL values require special attention.
- It can be used with subqueries.
What does NOT IN do?
NOT IN returns rows whose value does not match any value in the specified list.
Why should NULL be considered when using NOT IN?
A NULL in the comparison set can cause SQL's three-valued logic to produce unexpected results, so NULL handling must be considered carefully.