Oracle Database Sql Certified Associate · Free Practice Question Easy
Question 8
View and examine the following available responses.
Indicate the responses which are equivalent to one another.
-
A
WHERE sales_price >= 100 AND sales_price <= 106; -
B
WHERE sales_price > 100 AND sales_price < 106; -
C
WHERE sales_price IN (100, 101, 102, 103, 104, 105, 106); -
D
WHERE sales_price BETWEEN 99 AND 106; -
E
WHERE sales_price BETWEEN 100 AND 106;
Reveal correct answers
Correct answers: A, E
Explanation
The equivalent responses are:
WHERE sales_price >= 100 AND sales_price <= 106;WHERE sales_price BETWEEN 100 AND 106;
Both BETWEEN and the combination of >= and <= operators are inclusive. This means they both include the starting and ending values in the range.
The other options are not equivalent:
WHERE sales_price IN (100, 101, 102, 103, 104, 105, 106);This is only equivalent ifsales_pricecan only take on integer values. Ifsales_pricecan be a decimal (e.g., 100.5), then thisINclause would not include it, whereas theBETWEENand>= <=clauses would.WHERE sales_price BETWEEN 99 AND 106;This includes 99, which the first two do not.WHERE sales_price > 100 AND sales_price < 106;This is exclusive, meaning it does not include 100 or 106.
Oracle IN
The Oracle IN operator determines whether a value matches any values in a list or a subquery. The IN is looking for specific values. There are many decimal values between 101 and 106 which the IN values (100, 101, 102, 103, 104, 105, 106) do not account for.
- expression IN (subquery)
Oracle BETWEEN
The BETWEEN operator is inclusive of the beginning and end range. The BETWEEN operator allows you to specify a range to test. When you use the BETWEEN operator to form a search condition for rows returned by a SELECT statement, only rows whose values are in the specified range are returned.
The following illustrates the syntax of the BETWEEN operator:
- expression BETWEEN low AND high
A. The WHERE clause with the >= (greater than or equal to) and <= (less than or equal to) operators checks for values that fall within the specified range, in this case, between 100 and 106, inclusive.
B. The WHERE clause with the > (greater than) and < (less than) operators checks for values that fall within the specified range but excludes the boundary values. In this case, it checks for sales_price values greater than 100 and less than 106.
C. The WHERE clause with the IN operator checks for values that match any of the specified values in the list. In this case, it checks for sales_price values of 100, 101, 102, 103, 104, 105, and 106 individually.
D. The WHERE clause with the BETWEEN operator checks for values that fall within the specified range, including the boundary values. In this case, it checks for sales_price values between 99 and 106, inclusive.
E.
The WHERE clause with the BETWEEN operator checks for values that fall within the specified range, including the boundary values. In this case, it checks for sales_price values between 100 and 106, inclusive.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
