All Type Coding

Search Here

ORDER BY Clause in sql server.

ORDER BY

The SQL ORDER BY clause is used to sort the data in ascending or descending order, based on one or more columns. The ORDER BY keyword sorts the records in ascending order by default.The ORDER BY clause can only be used in SELECT statements.

Syntax:
                      Select * from table_name where [Condition]
                Order by expression DESC OR ASC           

We can use more than one column in the ORDER BY clause to sort the data in ascending or descending form.
Let's Consider the Employee1 table having the following records:











Now We'll sort the result in descending order by Name and Gender:


















Following is an example, which would sort the result in ascending order by Name:





















No comments :

Post a Comment