Oracle Database Administration I — Question 14
Which two statements are true about the ORDER BY clause when used with a SQL statement containing a SET operator such as UNION? (Choose two.)
Answer options
- A. Column positions must be used in the ORDER BY clause
- B. Only column names from the first SELECT statement in the compound query are recognized
- C. The first column in the first SELECT of the compound query with the UNION operator is used by default to sort output in the absence of an ORDER BY clause
- D. Each SELECT statement in the compound query must have its own ORDER BY clause
- E. Each SELECT statement in the compound query can have its own ORDER BY clause
Correct answer: B, C
Explanation
Option B is correct because only the column names from the first SELECT statement are considered in the ORDER BY clause when using UNION. Option C is also correct since, without an ORDER BY clause, the first column of the first SELECT is used for sorting by default. Options A, D, and E are incorrect because they imply requirements that do not apply to the use of ORDER BY with UNION.