«Back to Home

Oracle Jump Start

Topics

How to Use Order by Clause In Oracle

Description
 
This command is used to order the columns data in an ascending or descending order.
 
Syntax
  1. Select  
  2. Expression  
  3. from  
  4. Table  
  5. Order By  
  6. Expression [ASC | DESC];  
Example
  1. Select  
  2. *  
  3. from  
  4. Employee; 
1
  1. Select  
  2. *  
  3. from  
  4. Employee  
  5. Order by  
  6. salary;  
2 
 
Example
 
This example displays sorting in an ascending order.
  1. Select  
  2. *  
  3. from  
  4. Employee  
  5. Order by  
  6. salary Asc;  
3
 
Example
 
This example displays sorting in the descending order.
  1. Select  
  2. *  
  3. from  
  4. Employee  
  5. Order by  
  6. salary Desc;  
4
 
Example
 
This example displays sorting by relative position.
  1. Select  
  2. *  
  3. from  
  4. Employee  
  5. Order by  
  6. Desc;  
5 
 
Summary
 
Thus, we learnt, Order By clause is used to order column data in an ascending or descending order. We learnt, how to use this clause in Oracle with the examples.