Introduction:

 

In this article we will explain how to use ORDER BY  Keyword in SQL Server or what is 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 "STUDENTtable, sorted ascending by the "Name" column.

SELECT * FROM STUDENT ORDER BY Name ASC

  • Result:


     

      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:


i hope this article will help to you.

0 comments


Leave a comment

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

Welcome to SQL Tutorials Point

Don't have an account? Click here to Create a new account, it takes less than a minute.