QuestionQ83

VerifiedRestricting and Sorting Data

Consider 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 of them?

Explanation

Oracle SQL allows an ORDER BY clause to use an integer position from the select list. Position 2 refers to salary, the second selected column, and DESC sorts that column in descending order. Thus, both statements use the same ordering criterion.

Learn more

Community Discussion

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