Skip to content
Worked Examples · Example 9.9

Q.The following query selects details of all the employees in ascending order of their salaries.

Puducherry TnboardTextbookSubjective· 2mImportance★★★★★
18% · 17/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 sorts ascending by default (lowest first). Run against the chapter's own EMPLOYEE table (Table 9.8), it lists all 10 employees from Aaliya (10000) to Kritika (60000).

The query

SELECT *
FROM EMPLOYEE
ORDER BY Salary;

No WHERE clause is needed since the question asks for all employees, just sorted. ORDER BY without ASC/DESC defaults to ascending.

Sorting Table 9.8 by Salary

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

Output:

+-------+----------+--------+-------+--------+
| EmpNo | Ename    | Salary | Bonus | DeptId |
+-------+----------+--------+-------+--------+
|   101 | Aaliya   |  10000 |   234 | D02    |
|   107 | Vergese  |  15000 |  NULL | D01    |
|   104 | Gurpreet |  19000 |   565 | D04    |
|   108 | Nachaobi |  29000 |  NULL | D05    |
|   105 | Joseph   |  34000 |   875 | D03    |
|   109 | Daribha  |  42000 |  NULL | D04    | …

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.