Oracle Database 12c: SQL Fundamentals — Question 21
Evaluate the following SQL statement:
SQL> SELECT cust_id, cust_last_name "Last Name"
FROM customers -
WHERE country_id = 10 -
UNION -
SELECT cust_id CUST_NO, cust_last_name
FROM customers -
WHERE country_id = 30;
Which ORDER BY clause are valid for the above query? (Choose all that apply.)
Answer options
- A. ORDER BY 2, 1
- B. ORDER BY CUST_NO
- C. ORDER BY 2, cust_id
- D. ORDER BY "CUST_NO"
- E. ORDER BY "Last Name"
Correct answer: A, C, E
Explanation
The correct answers are A, C, and E because they reference valid column positions or aliases in the result set of the UNION query. Option B is incorrect as it uses an alias that is not defined in the first SELECT statement. Option D is also incorrect since it uses the alias in a way that does not match the column names in the final result set.