SQL Tutorial : DRL / DQL - ORDER BY CLAUSE
Let's learn about next topic: ORDER BY CLAUSE
ORDER BY CLAUSE:
*****************
- USED FOR ARRANGING THE SELECTED RECORDS IN
- ASCENDING OR DESCENDING ORDER
- DEFAULT IS ASC
- ORDER BY CLAUSE IS THE LAST CLAUSE IN THE SELECT STATEMENT
eg:
- SELECT DEPARTMENT_ID
FROM EMPLOYEES
ORDER BY DEPARTMENT_ID ASC
- SELECT DEPARTMENT_ID,SALARY
FROM EMPLOYEES
ORDER BY DEPARTMENT_ID ASC, SALARY DESC
- SELECT DEPARTMENT_ID,SALARY SAL
FROM EMPLOYEES
ORDER BY DEPARTMENT_ID ASC, SAL DESC
Point to note:
- ALIASE NAMES CAN BE USED IN ORDER BY CLAUSE
- ALIASE NAMES CANNOT BE USED IN COMPUTATIONS
No comments:
Post a Comment