Guides/SQL BETWEEN
📘
SQL Guide

SQL BETWEEN

Filter values inside an inclusive range.

What & Why

The BETWEEN operator is used to match values inside an inclusive range — both endpoints are included. BETWEEN makes range filters easy to read for spend bands, score bands, and calendar windows where both boundaries should be included.

See how it works

Marketing wants campaigns with moderate spend for a mid-budget review.

SELECT
  name,
  channel,
  spend
FROM marketing.campaigns
WHERE spend BETWEEN 1000 AND 10000
ORDER BY spend DESC;

Syntax pattern

See explanation
WHERE column_name BETWEEN low_value AND high_value
  • BETWEEN includes both endpoints.
  • It works for numbers, dates, and ordered text.
  • For timestamps, half-open date ranges are often safer.
Now You Try

Practice this concept hands-on

Sign up for a free account to run SQL against real datasets right here in the browser and get instant AI feedback. No credit card required.

Sign up free