Oracle Database Sql Certified Associate · Free Practice Question Medium

Question 6

View and examine the description of the BOOKS_TRANSACTIONS table and exhibit.

Table: BOOKS_TRANSACTIONS


Examine this partial SQL statement.

Exhibit: 1


Identify two WHERE conditions render the same result. (Choose two)

  • A
  • B
  • C
  • D
  • E
Reveal correct answers

Correct answers: A, E

Explanation

The two WHERE conditions that render the same result are:

1.

2.



Both conditions logically evaluate the same set of records because:

  1. First condition:

    • borrowed_date = SYSDATE

    • AND (either transaction_type = 'RM' or member_id IN ('A101', 'A102'))

    • This means only records where borrowed_date = SYSDATE are considered, but within those, it allows either transaction_type = 'RM' or specific member_ids.

  2. Second condition:

    • (borrowed_date = SYSDATE AND transaction_type = 'RM')

    • OR member_id IN ('A101', 'A102')

    • This means:

      • Either (borrowed_date = SYSDATE and transaction_type = 'RM') OR

      • Any row where member_id IN ('A101', 'A102'), regardless of borrowed_date.

    • This effectively produces the same result as the first condition.


Why the Other Options Are Incorrect:

  • This condition allows all records where borrowed_date = SYSDATE, even if they don’t match transaction_type = 'RM' or member_id conditions.

  • It’s too broad and includes extra rows.

  • Due to operator precedence, this condition is evaluated as:

    • Which is the same as the second correct condition.

    • However, because it lacks parentheses, its meaning is ambiguous and should be avoided in favor of clearer syntax.

  • This is interpreted as:

    • This allows all records where member_id = 'A102', regardless of borrowed_date, making it incorrect.

A. This WHERE condition checks for rows where either the borrowed date is the current date and the transaction type is 'RM', or the member ID is either 'A101' or 'A102'. This condition will return results where either of the two conditions is met, making it equivalent to the first condition.

B. This WHERE condition checks for rows where the borrowed date is the current date, the transaction type is 'RM', and the member ID is either 'A101' or 'A102'. This condition will only return results where all three conditions are met, making it different from the other conditions.

C. This WHERE condition checks for rows where the borrowed date is the current date and the transaction type is 'RM', or the member ID is either 'A101' or 'A102'. This condition will return results where either of the two conditions is met.

D. This WHERE condition checks for rows where the borrowed date is the current date, or the transaction type is 'RM' and the member ID is either 'A101' or 'A102'. This condition will return results where either the borrowed date is the current date, or both the transaction type is 'RM' and the member ID is either 'A101' or 'A102'.

E. This WHERE condition checks for rows where the borrowed date is the current date and the transaction type is 'RM', or the member ID is either 'A101' or 'A102'. This condition will return results where either of the two conditions is met, making it equivalent to the first condition.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need