Introduction:

 

 In this tutorial we will learn how to use ORDER BY Keyword in SQL Server or how    to sorting the data in ascending or descending order in SQL Server with example.

 

Description:

 

The ORDER BY Keyword is used to sort the data in ascending or descending order, based on one or more columns. The ORDER BY keyword by default sort the data in ascending.

ORDER BY Syntax:

SELECT column1, column2, columnN
FROM table_name
ORDER BY column1, column2, columnN  ASC|DESC;
  • ORDER BY ASC EXAMPLE

    The following SQL statement select all student from the "student" table, sorted ascending by the "Name" column. 

SELECT * FROM STUDENT ORDER BY Name ASC

  • Result:

Order By in SQL     

     ORDER BY DESC Example

The following SQL statement select all STUDENT from the "STUDENT" table, sorted descending by the "Name" column.

SELECT * FROM STUDENT ORDER BY Name DESC

  • Result:

Order By in SQL

i hope this article will help to you.


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like