QuestionQ36

VerifiedUsing the SET Operators

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 clauses are valid for the query shown above?

Choose two
Explanation

For a compound query that uses UNION, Oracle requires ORDER BY to use select-list positions or column aliases rather than explicit column expressions. 2, 1 are valid positions, and "Last Name" is the quoted alias assigned in the first SELECT list. CUST_NO is not an output alias of the first SELECT, and cust_id is an unaliased column reference.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!