skip to today's puzzle

BETWEEN covers a range of values

Starting table: drinks

Starting drinks data before the example query
nameprice
Kids cocoa2.50
Espresso3.00
Latte4.50
Cold brew6.00
Pour-over7.50

BETWEEN is a short way of saying 'at least this, and at most that'. You give the low value first and the high value second. Both ends count: BETWEEN 3 AND 6 includes a price of exactly 3 and a price of exactly 6. The low and high values are included, not skipped.

A tiny example

In plain English: Show me the name and price of drinks priced anywhere from 3 to 6.

SELECT name, price
FROM drinks
WHERE price BETWEEN 3 AND 6;

Query result

nameprice
Espresso3.00
Latte4.50
Cold brew6.00

Espresso at exactly 3.00 and Cold brew at exactly 6.00 both appear in your results, because both ends count. Latte at 4.50 sits in between. Kids cocoa (2.50) and Pour-over (7.50) fall outside the range.

Common questions

Is BETWEEN inclusive in SQL?
Yes. BETWEEN 3 AND 6 means price >= 3 AND price <= 6, so a price of exactly 3 or exactly 6 is kept. This is the same in PostgreSQL, MySQL, SQLite, SQL Server and BigQuery.
Is BETWEEN safe for dates with times?
Be careful: BETWEEN '2025-06-01' AND '2025-06-30' stops at midnight at the start of June 30, so later orders that day are dropped. For timestamps, use >= the first day and < the next day instead.

Related SQL lessons

Practice BETWEEN step by step

The Foundations Track has beginner puzzles built around this idea. Tap tiles, see real results. No terminal, no setup.

practice this in the course

Ready for a break?

A fresh, bite-sized SQL puzzle waits every morning. Tap tiles, see real results. No terminal, no setup, no timers.

Try today's free SQL puzzle