Basics · Lesson 7 of 19

Range Queries with BETWEEN

BETWEEN filters values within a range (inclusive).

SELECT * FROM employees
WHERE salary BETWEEN 70000 AND 90000;

This is the same as:

WHERE salary >= 70000 AND salary <= 90000

BETWEEN works with:

  • Numbers
  • Dates
  • Text (alphabetically)

Both endpoints are included!

Check your understanding

Find employees earning between $75,000 and $95,000.

Examples run on the employees sample database. Open any of them in the playground to experiment.

Practice it on a real question

All SELECT & filtering questions

Practice on your iPhone

Query Dojo for iPhone has 85 interview questions, timed mock interviews and a tile builder, so you can write queries without a keyboard.

Get the app