You want the results of the query to be displayed in a sorted order based on some query. In this case , you use the ORDER BY clause in the query by specifying the column on which the sort to work.
For example , you want to sort the Departments table in the database by the column DepartmentName. Here’s how the query looks like
Use AdventureWorks2014 GO SELECT * from HumanResources.Department ORDER BY Name
This query would return the departments sorted in ASCENDING ORDER by default on the column “Name”.
Leave a Reply