Tech Junkie Blog - Real World Tutorials, Happy Coding!: SQL: Sort By Multiple Columns

Friday, February 6, 2015

SQL: Sort By Multiple Columns

SELECT UnitPrice, ProductName
FROM Products
ORDER BY UnitPrice DESC, ProductName

The query above sorts the results based on the most expensive products, and then the product name. Useful if you want a secondary sort criteria. For example if there are multiple products that are $14.00 then those products will be sorted by their names after the price has been sorted.

No comments:

Post a Comment

Search This Blog