How to order results in SQL? ORDER BY

A basic  query of the HumanResources.Department table bring s the following results.


If you wanted to reverse the order of the DepartmentID then you would need to user the ‘ORDER BY’ clause.

The default sort is always ascending ( ASC) but it does not have to be explicitly written. If you want the order to be reversed then you would need to use DESC ( descending).



Sorting of results can also be done on numbers, dates, letters……


Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: