Transact SQL Other Articles Software Reviews
Using the Transact SQL Order Desc Ordering Statement
The SQL Desc keyword can be used to change the order that rows are returned in a results set if the Order By clause is used in a query. If Desc is specified then the results are ordered in descending order.
This SQL statement retrieves a list of products:
SELECT * FROM Products
This SQL statement will retrieve the products from the Products table in alphabetical order:
SELECT * FROM Products ORDER BY ProductName
Note that null values for ProductName will appear first.
If the Desc keyword is used then the ordering of the rows will be reversed, so that product names beginning with Z will be at the top of the list.
SELECT * FROM Products ORDER BY ProductName DESC
The Desc keyword can also sort numerical column values so that if Desc is used the highest values are shown first.
There is also an Asc keyword, but since this is the default ordering for SQL results set rows it's not always required.