1z0-061 Exam QuestionsBrowse all questions from this exam

1z0-061 Exam - Question 30


Evaluate these two SQL statements:

SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY salary DESC;

SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC;

What is true about them?

Show Answer
Correct Answer:

The two SQL statements produce identical results. The first statement explicitly orders by the salary column in descending order. The second statement orders by the second column in the SELECT clause, which is also the salary column, in descending order. Therefore, both statements will order the results by the salary column in descending order, leading to identical results.

Discussion

1 comment
Sign in to comment
Blob44Option: A
Jan 9, 2023

column aliases and/or number as order in the select for the col are allowed in order by clause. default is ASC so DESC is needed