programplug Logo



SQL Orderby

ORDER BY



The SQL order by clause is used to arrange the data in systematic way like ascending or descending order which is based on one or more column.

Syntax:
SELECT column 
FROM table_name 
[WHERE condition] 
[ORDER BY column1, column2,coloumn3 .. columnN] [ASC / DESC];
			 
	
Example of ASCENDING ORDER:
c_id c_name c_age c_experince
01 Frank 37 7
02 Lennin 27 2
03 andy 41 6
04 Peter 29 3
05 Mike 44 8

Example of DESCENDING ORDER:
SQL> SELECT * FROM Teacher
   ORDER BY NAME DESC;
			 
	
Output:
c_id c_name c_age c_experince
03 andy 41 6
01 Frank 37 7
05 Mike 44 8
02 Lennin 27 2
03 andy 41 6