Microsoft SQL Server ORDER BY multiple fields


Multiple fields can be specified for the ORDER BY clause, in either ASCending or DESCending order.

For example, using the table, we can return a query that sorts by SaleDate in ascending order, and Quantity in descending order.

SELECT ItemId, SaleDate, Quantity
FROM [Item Sales]
ORDER BY SaleDate ASC, Quantity DESC

Note that the ASC keyword is optional, and results are sorted in ascending order of a given field by default.