Use the ORDER BY keyword to sort results with a SELECT statement.  You can sort over multiple columns, in both ascending and descending order. 

Here products are sorted by ListPrice

SELECT ProductNumber, Name, ListPrice FROM Production.Product ORDER BY ListPrice
/* Answer */
SELECT   ProductNumber, Name, ListPrice 
FROM     Production.Product 
ORDER BY ListPrice 

ORDER BY Multiple Fields 

You can sort by more than one field.  Separate each column with a comma.

SELECT ProductNumber, Name, ListPrice FROM Production.Product ORDER BY ListPrice, Name
/* Answer */
SELECT   ProductNumber, Name, ListPrice 
FROM     Production.Product 
ORDER BY ListPrice, Name 

ORDER BY Keyword and DESC 

To sort a column in descending (9-0) order use the DESC keyword.

SELECT ProductNumber, Name, ListPrice FROM Production.Product ORDER BY ListPrice DESC
/* Answer */
SELECT   ProductNumber, Name, ListPrice 
FROM     Production.Product 
ORDER BY ListPrice DESC 

ORDER BY and ASC 

To sort in ascending order (0-9) use ASC, which stand for Ascending.

SELECT ProductNumber, Name, ListPrice FROM Production.Product ORDER BY ListPrice ASC
/* Answer */
SELECT   ProductNumber, Name, ListPrice 
FROM     Production.Product 
ORDER BY ListPrice ASC

This is the default behavior, so you can opt to leave it off, as we did in the first examples. 

In summary use the ORDER BY keyword to sort your result. 

You can specify one or more columns. 

Place either DESC or ASC after each column to sort them in descending or ascending order, respectively. 

Additional Resources

To learn more about the ORDER BY, check out these useful resources: 

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>