Consider the following Oracle SQL query: SELECT * FROM Products WHERE Price…
2018
Consider the following Oracle SQL query:
SELECT * FROM Products
WHERE Price BETWEEN 10 AND 20;
Which of the following is the correct interpretation of this query?
- A.
Select all products whose price is greater than 10 but less than 20
- B.
Select all products whose price is greater than or equal to 10 but less than 20
- C.
Select all products whose price is greater than 10 but less than or equal to 20
- D.
Select all products whose price is greater than or equal to 10 but less than or equal to 20
Attempted by 342 students.
Show answer & explanation
Correct answer: D
The BETWEEN operator in Oracle SQL (and standard SQL) is always inclusive. This means it includes both the start value and the end value in the results.
Boundary Values: If a product costs exactly 10 or exactly 20, it will be included in your results.
Order of Values: Always remember that the smaller number must come first. Writing
BETWEEN 20 AND 10would return zero rows because SQL evaluates it strictly from low to high.