Given a table 'EMPLOYEE' as follows:
EMPID EmpName DOB DOJ Salary E001 Sumit 1994-10-10 2020-05-05 50000 E002 Ajay 1995-08-11 2021-07-08 60000 E003 Amit 1993-04-14 2012-04-09 70000
Which of the query below will arrange and display the same table in descending order by 'Salary'?
Given a table 'EMPLOYEE' as follows:
| EMPID | EmpName | DOB | DOJ | Salary |
|---|---|---|---|---|
| E001 | Sumit | 1994-10-10 | 2020-05-05 | 50000 |
| E002 | Ajay | 1995-08-11 | 2021-07-08 | 60000 |
| E003 | Amit | 1993-04-14 | 2012-04-09 | 70000 |
Which of the query below will arrange and display the same table in descending order by 'Salary'?
Solution
✅ Correct Option: 3
ORDER BY sorts the rows of a result, and DESC makes the order descending. SELECT * FROM EMPLOYEE ORDER BY Salary DESC; displays all columns of the table, with the highest salary first: E003 (70000), E002 (60000), E001 (50000).
Options 1 and 2: HAVING filters groups and WHERE filters rows. Neither sorts, and DESC is not valid after them.
Option 4: it sorts correctly but shows only the Salary column, not the whole table.
Related questions:
2025: 21 May Shift 1
2026: 13 May Shift 2