NOT BETWEEN returns rows where a value falls outside the specified inclusive range.
Exclusion ranges are useful when analysts need to identify records outside acceptable or expected limits.
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;
NOT BETWEEN can support exception reporting, risk analysis, quality checks, and threshold monitoring.
- NOT BETWEEN excludes a range.
- The specified range is normally inclusive.
- Values below or above the range are returned.
- It can be used with numeric values.
- It can also be used with dates.
What does NOT BETWEEN do?
NOT BETWEEN returns values outside the specified range.
Are boundary values excluded by NOT BETWEEN?
Yes. Because BETWEEN includes its boundaries, NOT BETWEEN excludes those boundary values as well.