NOT BETWEEN returns rows where the specified value does not fall within the given inclusive range.
Exclusion ranges are useful when business rules require identifying records outside an acceptable range.
Find employees whose salaries are outside the ₹50,000 to ₹80,000 range.
SELECT
EmployeeName,
Salary
FROM Employees
WHERE Salary NOT BETWEEN 50000 AND 80000;
It can be used for exception reporting, salary analysis, transaction monitoring, and identifying values outside expected limits.
- NOT BETWEEN excludes a range.
- The specified range itself is inclusive.
- It can simplify range exclusion logic.
- It can be used with numeric values.
- It can also be used with dates.
What does NOT BETWEEN do?
It returns values outside the specified range.
Are the BETWEEN boundaries still inclusive with NOT BETWEEN?
Yes. NOT BETWEEN excludes the entire inclusive BETWEEN range.