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
- Select
- Expression
- from
- Table
- Order By
- Expression [ASC | DESC];
Example
- Select
- *
- from
- Employee;
- Select
- *
- from
- Employee
- Order by
- salary;
Example
This example displays sorting in an ascending order.
- Select
- *
- from
- Employee
- Order by
- salary Asc;
Example
This example displays sorting in the descending order.
- Select
- *
- from
- Employee
- Order by
- salary Desc;
Example
This example displays sorting by relative position.
- Select
- *
- from
- Employee
- Order by
- 1 Desc;
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.