Skip to content
Worked Examples · Example 9.10

Q.Select details of all the employees in descending order of their salaries.

Yanam CbseNCERTSubjective· 2mImportance★★★★★
20% · 19/95 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

ORDER BY Salary DESC sorts descending (highest first). Run against the chapter's own EMPLOYEE table (Table 9.8), it lists all 10 employees from Kritika (60000) down to Aaliya (10000).

The query

SELECT *
FROM EMPLOYEE
ORDER BY Salary DESC;

ORDER BY without DESC sorts ascending by default (as in the previous Example 9.9); adding the DESC keyword reverses it, so the employee with the highest salary appears first.

Sorting Table 9.8 by Salary, descending

SalaryEmpNoEname
60000102Kritika
50000110Tanya
48000106Sanya
45000103Shabbir
42000109Daribha
34000105Joseph
29000108Nachaobi
19000104Gurpreet
15000107Vergese
10000101Aaliya

Output:

mysql> SELECT   * FROM EMPLOYEE
    -> ORDER BY Salary DESC;
+-------+----------+--------+-------+--------+
| EmpNo | Ename    | Salary | Bonus | DeptId |
+-------+----------+--------+-------+--------+
|   102 | Kritika  |  60000 |   123 | D01    |
|   110 | Tanya    |  50000 |   467 | D05    |
|   106 | Sanya    |  48000 |   695 | D02    |
|   103 | Shabbir  |  45000 |   566 | D01    |
|   109 | Daribha  |  42000 |  NULL | D04    |
|   105 | Joseph   |  34000 |   875 | D03    | …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.