Skip to content
/ Chapter 3 · Filtering in Depth
Lesson 3.4 · garden_shop
Lesson 3.4

SQL BETWEEN Operator: Filtering Ranges

Range filters are cleaner when the lower and upper bounds are written together.

BETWEEN checks whether a value is inside a range. It is often clearer than writing one condition for the lower bound and another condition for the upper bound.

The important detail: BETWEEN is inclusive. A value equal to the start or end of the range is included.

That is why a month range written with BETWEEN works on order_date, which holds plain dates. On a column that also stores a time, the last day's later hours would fall outside the range. Lesson 7.1 shows the half-open range that avoids that.

Pattern
select column_one, column_two
from table_name
where column_name between lower_value and upper_value
Schema · Garden Shop Table · orders 6 columns · 24 rows
Table · orders

One row per order. Unshipped orders have a null shipped_date.

6 columns · 24 rows
order_id int customer_id int order_date date shipped_date date status text coupon_code text
Your task

Show the order id, order date, and status for orders placed during March 2024.

·

Run your query to inspect the result.

Expected answer
  • Columns: order_id, order_date, status.
  • Rows: 4 March orders.
  • Dates should run from 2024-03-02 through 2024-03-30.