0
0
SQLquery~5 mins

WHERE with BETWEEN range in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the SQL BETWEEN operator do in a WHERE clause?
The BETWEEN operator filters the results to include only rows where a column's value falls within a specified range, including the boundary values.
Click to reveal answer
beginner
Write a SQL query to select all products with prices between 10 and 20 inclusive.
SELECT * FROM products WHERE price BETWEEN 10 AND 20;
Click to reveal answer
beginner
Is the BETWEEN operator inclusive or exclusive of the range boundaries?
The BETWEEN operator is inclusive, meaning it includes both the start and end values of the range.
Click to reveal answer
intermediate
Can BETWEEN be used with dates in SQL?
Yes, BETWEEN works with dates to filter rows where a date column falls within a specified date range.
Click to reveal answer
intermediate
What is the equivalent of WHERE column BETWEEN 5 AND 10 using comparison operators?
It is equivalent to WHERE column >= 5 AND column <= 10.
Click to reveal answer
Which of the following SQL queries correctly selects rows where age is between 18 and 30 inclusive?
ASELECT * FROM users WHERE age > 18 AND age < 30;
BSELECT * FROM users WHERE age = 18 AND age = 30;
CSELECT * FROM users WHERE age >= 18 OR age <= 30;
DSELECT * FROM users WHERE age BETWEEN 18 AND 30;
What will the query SELECT * FROM orders WHERE order_date BETWEEN '2024-01-01' AND '2024-01-31'; return?
AOrders placed from January 1 to January 31, 2024, inclusive.
BOrders placed only on January 1 and January 31, 2024.
COrders placed before January 1, 2024.
DOrders placed after January 31, 2024.
Which of these is NOT true about the BETWEEN operator?
AIt includes the boundary values.
BIt can be used with numbers, dates, and text.
CIt is case-sensitive when used with text.
DIt can replace multiple comparison operators.
How would you rewrite WHERE score BETWEEN 50 AND 100 using only comparison operators?
AWHERE score >= 50 AND score <= 100
BWHERE score = 50 OR score = 100
CWHERE score > 50 OR score < 100
DWHERE score > 50 AND score < 100
If you want to find records where a value is NOT between 10 and 20, which SQL clause would you use?
AWHERE value BETWEEN 10 AND 20
BWHERE value NOT BETWEEN 10 AND 20
CWHERE value >= 10 AND value <= 20
DWHERE value = 10 OR value = 20
Explain how the BETWEEN operator works in a SQL WHERE clause and give an example.
Think about filtering rows within a range of values.
You got /3 concepts.
    Describe how you can use BETWEEN with dates and why it might be useful.
    Consider filtering records within a specific time period.
    You got /3 concepts.