Which statement is true regarding the output of the SQL statement?

Evaluate the following SQL statement:
SELECT 2 col1,’y’ col2
FROM dual
UNION
SELECT 1,’x’
FROM dual UNION
SELECT 3,NULL
FROM dual
ORDER BY 2;
Which statement is true regarding the output of the SQL statement?

Evaluate the following SQL statement:
SELECT 2 col1,’y’ col2
FROM dual
UNION
SELECT 1,’x’
FROM dual UNION
SELECT 3,NULL
FROM dual
ORDER BY 2;

Which statement is true regarding the output of the SQL statement?

A.
It would execute and the order of the values in the first column would be 3, 2, 1.

B.
It would execute and the order of the values in the first column would be 1, 2, 3.

C.
It would not execute because the column alias name has not been used in the ORDER BY clause.

D.
It would not execute because the number 2 in the ORDER BY clause would conflict with the value 2 in the first SELECT statement.



Leave a Reply 6

Your email address will not be published. Required fields are marked *


Anurag

Anurag

the option b is correct
because the union set operator produce output in acceding order

user

user

SELECT 2 col1,’y’ col2
FROM dual
UNION
SELECT 1,’x’
FROM dual UNION
SELECT 3,NULL
FROM dual
ORDER BY 2 desc;

Rajiv R Mishra

Rajiv R Mishra

none of the answers is correct
it will display as 2,1,3

dames

dames

B.
Tested:

COL1 C
———- –
1 x
2 y
3

shadow

shadow

can anyone give Clear Explanation please.

Renata

Renata

•Character data is sorted by default in ascending order, from ‘A’ to ‘Z’.
•ORDER BY can identify columns by column alias, or by position within the SELECT list.
• Null always be the biggest value, defaul is ascending Then null value is the last