Ads

Tuesday, March 25, 2014

SQL ORDER BY

The ORDER BY clause is used in a SELECT statement to sort results either in ascending or descending order. Oracle sorts query results in ascending order by default.

SQL> Select ename,sal, from emp where sal > 100 order by ename desc; (DESCENDING ORDER)
 
SQL> Select ename,sal from emp where sal > 100 order by ename (BY DEFAULT ASCENDING ORDER)

 SQL> Select ename,sal,comm from emp order by 1;
            (In the Above Query ORDER BY 1 is Taking Column Name from Select Option)
             Ename-> Column 1.
             Sal-> Column 2.





No comments:

Post a Comment

Contact Us

Name

Email *

Message *