SQL BETWEEN

Select values within a range.

✍️ 3 exercises + code challenge in this lesson

BETWEEN a AND b selects values within a range, including both ends. It works with numbers, text and dates.

NOT BETWEEN selects values outside the range.

Key Takeaways: SQL BETWEEN

Mastering SQL BETWEEN helps you write clean and reliable SQL code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

SQL BETWEEN Code Example

SQL
SELECT ProductName, Price FROM Products
WHERE Price BETWEEN 1000 AND 30000
ORDER BY Price;

SELECT OrderID, OrderDate FROM Orders
WHERE OrderDate BETWEEN '2026-03-01' AND '2026-06-30';
Free sign-in required · Google login available

SQL BETWEEN Practice Exercises

Check what you learned in “SQL BETWEEN”.

/ 3 solved
Fill in the blank

Select prices from 1000 to 5000.

WHERE Price  1000 AND 5000
✓ Correct! Not quite. Try again.
Multiple choice

Does BETWEEN include the boundary values?

✓ Correct! Not quite. Try again.
Code challenge

Select ProductName of products with a stock between 20 and 100, sorted by ProductName.

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services