The default sort order is ascending when using the ORDER BY clause , you can reverse the order in which rows are displayed by using the DESC keywords. It placed after column name in the ORDER BY clause
For Example
SELECT EMPNO,ENAME
FROM EMP
ORDER BY SAL DESC;
EMPNO ENAME SAL
For Example
SELECT EMPNO,ENAME
FROM EMP
ORDER BY SAL DESC;
EMPNO ENAME SAL
----- ---------- ----------
7839 KING 5000
7788 SCOTT 3000
7902 FORD 3000
7566 JONES 2975
7698 BLAKE 2850
7782 CLARK 2450
7499 ALLEN 1600
7844 TURNER 1500
7934 MILLER 1300
7521 WARD 1250
7654 MARTIN 1250
EMPNO ENAME SAL
----- ---------- ----------
7876 ADAMS 1100
7900 JAMES 950
7369 SMITH 800
Select ename,sal,mgr
From emp
Order by mgr DESC;
ENAME SAL MGR
---------- ---------- ----------
KING 5000
SMITH 800 7902
JONES 2975 7839
CLARK 2450 7839
BLAKE 2850 7839
ADAMS 1100 7788
MILLER 1300 7782
ALLEN 1600 7698
MARTIN 1250 7698
WARD 1250 7698
JAMES 950 7698
ENAME SAL MGR
---------- ---------- ----------
TURNER 1500 7698
SCOTT 3000 7566
FORD 3000 7566
No comments:
Post a Comment