How to order results in SQL? ORDER BY — Parv The IT Geek

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……


Originally published at https://parvtheitgeek.com on January 17, 2014.

Published by Parvinder Nijjar

I blog at ParvTheITGeek.com

Leave a comment