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

SQL: GROUP BY And HAVING

Installing AdventureWorks Sample Databases from Microsoft

Docker : Pull The Latest CentOS Image Into A Ubuntu Server