BETWEEN

The BETWEEN operators provides an option of expressing conditions within some upper and lower bound. The BETWEEN operators is restricted to data types that can be evaluated based on their ranges i.e. numeric types (INT, floats, and doubles) and dates. Let's demonstrate this with an example.

Example:
Suppose we are interested in information for the orders table about all columns whose freight order value is between 10 and 20 loads. The filter for this result, we write the following query using the BETWEEN clause.

select *
from orders
where freight between 10 and 20
| order_id | customer_id | ship_country | ship_via | freight | order_date |
| -------- | ----------- | ------------ | -------- | ------- | ---------- |
| 3002     | 2002        | Germany      | 2        | 18.75   | 2023-01-20 |
| 3006     | 2006        | UK           | 1        | 15.6    | 2023-02-10 |
| 3008     | 2008        | France       | 2        | 19.45   | 2023-02-20 |
| 3011     | 2011        | Germany      | 1        | 12.3    | 2023-03-05 |
| 3014     | 2014        | Canada       | 1        | 16.75   | 2023-03-20 |

Notice that the resulting output contains records whose total invoice value that is between the parameters we set in the query, 10 to 20 freight load. Like I mentioned earlier, the BETWEEN operator can be used to evaluate numerics and date data types to filter for a narrow subset of data to meet your querying needs.

This concludes our discussion of the BETWEEN clause. In the section, we look at the IN operator to filter for a finite set of matching criteria.