Order by clause
- By using this rows can be sorted
- It is used in the last portion of select statement
- By default it gets ascending order
- DESC: is used for sorting in descending order
- Sorting by column Alias
- Sorting by column which is not in select list is possible
Example:
SELECT EMPNO, ENAME, SAL*12 "ANNUAL" FROM EMP
ORDER BY ANNUAL;
Example: //Sorting by multiple columns//; ascending order on department number and descending order of salary in each department.
SELECT ENAME, DEPTNO, SAL FROM EMP
ORDER BY DEPTNO, SAL DESC;