Back to Top

How to use order by clause in SQL Server

SQL SERVER : ORDER BY 


Lets us see how to use the  SQL ORDER BY clause. Following is the syntax and examples given for the reference and DIY use. 

Description
This  ORDER BY clause is mainly useful in sorting the records in the result set for a SELECT statement in SQL SERVER.

Syntax: ORDER BY


The  syntax in the SQL Server for the ORDER BY clause is as following :

SELECT  a
FROM table1
[WHERE condition]
ORDER BY expression ; 

The Order By Clause can be used with the following Arguments and the parameters. So here we are having list of the Arguments and Parameters to be use:----

1.ASC (Ascending)

The ASC sort the result of a SQL query in the ascending order . It is also can be as Default in a sql query.

2.DESC(Descending )

The DESC sort the result of a SQL query in the descending order . It display result from a higher value to a lower one.
3.expressions or Column value
The set or particular columns to be  retrieved from the table in SQL Result set.
4.tables
The tables from where one wants to retrieve the Detail or result from. There should be at least  a table or single table   in the FROM clause in the SQL Query.
5.WHERE conditions
Conditions is only applied when to get the records to be selected.

Note

  • The order by Clause uses the ASC as the default modifier in the result set of the SQL Query.

0comments

Post a Comment