Oracle Database 12c: SQL Fundamentals — Question 41

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?

Answer options

Correct answer:

Explanation

The correct answer is A, as both SQL statements will yield identical results; the second statement uses the column index to sort by salary, which is the same as explicitly stating 'salary'. Option B is incorrect because the second statement does not produce a syntax error. Option C is wrong since the default order for SQL is ascending, not descending. Option D is also incorrect because both statements already produce the same results without needing an alias.