Recall & Review
beginner
What does the SQL BETWEEN operator do?
The BETWEEN operator filters rows where a column's value is within a specified range, including the start and end values.
Click to reveal answer
beginner
Write a SQL query using BETWEEN to find all orders with amounts between 100 and 500.
SELECT * FROM orders WHERE amount BETWEEN 100 AND 500;
Click to reveal answer
beginner
Does BETWEEN include the boundary values in the range?
Yes, BETWEEN includes both the start and end values in the range check.
Click to reveal answer
intermediate
How is BETWEEN different from using >= and <= operators?
BETWEEN is a shorthand for using >= and <= together. For example, 'x BETWEEN a AND b' is the same as 'x >= a AND x <= b'.
Click to reveal answer
beginner
Can BETWEEN be used with dates in PostgreSQL?
Yes, BETWEEN works with dates to filter rows within a date range, including the start and end dates.
Click to reveal answer
Which of the following queries correctly finds products priced between 50 and 100?
✗ Incorrect
BETWEEN includes both 50 and 100, so option C correctly filters prices from 50 to 100 inclusive.
Does the BETWEEN operator include the boundary values in its range?
✗ Incorrect
BETWEEN includes both the start and end values in the range.
Which is equivalent to 'salary BETWEEN 3000 AND 7000'?
✗ Incorrect
BETWEEN is the same as using >= for the lower bound and <= for the upper bound.
Can BETWEEN be used to filter date columns in PostgreSQL?
✗ Incorrect
BETWEEN works with dates to filter rows within a date range.
What will this query return? SELECT * FROM sales WHERE sale_date BETWEEN '2024-01-01' AND '2024-01-31';
✗ Incorrect
BETWEEN includes both start and end dates, so it returns sales during the entire month of January 2024.
Explain how the BETWEEN operator works for filtering numeric ranges in SQL.
Think about how you check if a number is between two others.
You got /4 concepts.
Describe how you would use BETWEEN to filter rows by date in PostgreSQL.
Dates can be compared like numbers in SQL.
You got /4 concepts.