SQL BETWEEN
The BETWEEN
command allows you determine whether a given column's values (or result set) are between two values.
-- Works in PostgreSQL, MySQL, SQL Server, and Oracle
SELECT
*
FROM
rent_payments
WHERE
dollar_amount BETWEEN 1700 AND 1900;
rent_payments
table
building_id | payment_date | dollar_amount |
---|---|---|
1 | 3/1/2018 | 2000 |
1 | 3/2/2018 | 1500 |
2 | 3/1/2018 | 1800 |
2 | 3/3/2018 | 1900 |
1 | 4/2/2018 | 2000 |
1 | 4/2/2018 | 1500 |
2 | 4/1/2018 | 1800 |
2 | 4/2/2018 | 1900 |
Query results
building_id | payment_date | dollar_amount |
---|---|---|
2 | 3/1/2018 | 1800 |
2 | 3/3/2018 | 1900 |
2 | 4/1/2018 | 1800 |
2 | 4/2/2018 | 1900 |