Syntax:
SELECT {*/Column List} FROM TABLENAME [WHERE CONDITION] ORDER BY COLUMNNAME {ASC/DESC}
The default order is ascending order. It means if we does not specify any specific order then it automatically takes ascending order.
Example1: Write a query to display employ details in ascending order based on their department numbers(DEPTNO).
SELECT * FROM EMP ORDER BY DEPTNO ASC
Example2: Write a query to display employ details in descending order based on their employ numbers(EMPNO).
SELECT * FROM EMP ORDER BY EMPNO DESC
Example3: Write a query to display employ details in descending order based on their salaries(SAL)
SELECT * FROM EMP ORDER BY SAL DESC
Exampe4: Write a querey to display employ names and their salaries in descending order based on their salaries(SAL).
SELECT ENAME,SAL FROM ORDER BY SAL DESC
Example5: Write a query to display 10th department employs in ascending order based on their employ names(ENAME).
SELECT * FROM EMP WHERE DEPTNO=10 ORDER BY ENAME

No comments:
Post a Comment