The BETWEEN operator is used to filter values within a specified range. It can be used with numbers, dates, and other comparable values. BETWEEN normally includes both the lower and upper boundary values.
Business analysis frequently requires range-based filtering. Analysts may need to find transactions between two amounts, employees with salaries within a range, or sales made between two dates.
A manager wants to identify employees whose salaries are between ₹50,000 and ₹80,000. BETWEEN can be used to apply this range condition.
SELECT
EmployeeName,
Salary
FROM Employees
WHERE Salary BETWEEN 50000 AND 80000;
BETWEEN is useful for salary analysis, transaction analysis, sales analysis, date filtering, price analysis, and customer segmentation.
- BETWEEN filters values within a range.
- BETWEEN normally includes both boundary values.
- BETWEEN can be used with numbers.
- BETWEEN can be used with dates.
- BETWEEN can make range conditions easier to read.
What does BETWEEN do in SQL?
BETWEEN filters values that fall within a specified range.
Are BETWEEN boundary values included?
Yes. BETWEEN normally includes both the lower and upper boundary values.