Lesson 3.5
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.
Pattern
select column_one, column_two
from table_name
where column_name between lower_value and upper_valueSchema · Garden ShopTable · orders6 columns · 24 rows
Table · orders
6 columns · 24 rowsOne row per order. Unshipped orders have a null shipped_date.
order_id intcustomer_id intorder_date dateshipped_date datestatus textcoupon_code text
Your task
Show the order id, order date, and status for orders placed during March 2024.
SQL Workbench
⌘↵ to run·
Expected answer
- Columns: order_id, order_date, status.
- Rows: 4 March orders.
- Dates should run from 2024-03-02 through 2024-03-30.