Sorting the Data in a Query in SQL Server


This content was proof-read by Grammarly. You can Try Grammary for FREE

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”.

Sorting the Data in a Query in SQL Server
Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

%d bloggers like this: