Oracle Database Administration I — Question 6
Table ORDER_ITEMS contains columns ORDER_ID, UNIT_PRICE and QUANTITY, of data type NUMBER.
Examine these SQL statements:
Statement 1:
SELECT MAX(unit_price * quantity) `Maximum Order`
FROM order_items;
Statement 2:
SELECT MAX(unit_price * quantity) `Maximum Order`
FROM order_items -
GROUP BY order_id;
Which two statements are true?
Answer options
- A. Statement 1 returns only one row of output.
- B. Statement 2 returns only one row of output.
- C. Both statements will return NULL if either UNIT_PRICE or QUANTITY contains NULL.
- D. Both the statements give the same output.
- E. Statement 2 may return multiple rows of output.
Correct answer: A, E
Explanation
Statement 1 computes the maximum value across the entire dataset, resulting in only one row. In contrast, Statement 2 groups the results by ORDER_ID, which can lead to multiple maximum values, hence multiple rows of output. Therefore, options A and E are correct.