MainMenu

Home Java Overview Maven Tutorials

Sunday 15 January 2017

SQL ORDER BY with example

SQL ORDER BY with example

ORDER BY

Used to sort records, and by default it will sort records in AESC order


Table : Salary <
Emp_idEmp_nameEmp_regEmp_salary
01chandanE_0125000
02adhirajE_0230000
03raghuE_0335000
04AlaxE_0440000

Suppose you need to find the Emp_name which have Emp_reg = "R01" & Emp_id = 1

Select Emp_name, Emp_salary from Salary ORDERY BY Emp_salary RESULT:
Emp_nameEmp_salary
chandan25000
adhiraj30000
raghu35000
Alax40000

Consider above table again & suppose you need to short the record in desc order


Select Emp_name, Emp_salary from Salary ORDERY BY Emp_salary DESC RESULT:
Emp_nameEmp_salary
Alax40000
raghu35000
adhiraj30000
chandan25000

Tag:SQL order by with example, Use of SQL ORDER BY Keyword with example

No comments:

Post a Comment