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.

Comments

Popular posts from this blog

Docker : Adding Docker Repository Key and Updating Docker To The Latest Version

ASP.NET Core : Adding The Default View With _ViewStart.cshtml

Enable ASP.NET Core to Serve Static Files