Explain ORDER BY statement in SQL Server.
The ORDER BY clause is used to sort the output in the specified manner like ascending or descending.
Ex :
Select EmployeeName, EmployeeID from Employees order by EmployeeName Desc
This Query will display the Employee names in reverse alphabetical order.
Select EmployeeName, EmployeeID from Employees order by EmployeeName Desc, EmployeeID Asc
This Query will display the Employee names in reverse alphabetical order and the Employee ID in alphabetical order.
Ex :
Select EmployeeName, EmployeeID from Employees order by EmployeeName Desc
This Query will display the Employee names in reverse alphabetical order.
Select EmployeeName, EmployeeID from Employees order by EmployeeName Desc, EmployeeID Asc
This Query will display the Employee names in reverse alphabetical order and the Employee ID in alphabetical order.
Labels: ORDER BY statement in SQL Server
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home