Worked Examples · Example 9.9
Q.The following query selects details of all the employees in ascending order of their salaries.
Rajasthan RbseTextbookSubjective· 2mImportance★★★★★
18% · 17/95 Questions
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
| Salary | EmpNo | Ename |
|---|---|---|
| 10000 | 101 | Aaliya |
| 15000 | 107 | Vergese |
| 19000 | 104 | Gurpreet |
| 29000 | 108 | Nachaobi |
| 34000 | 105 | Joseph |
| 42000 | 109 | Daribha |
| 45000 | 103 | Shabbir |
| 48000 | 106 | Sanya |
| 50000 | 110 | Tanya |
| 60000 | 102 | Kritika |
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.