ORDER BY
clauseORDER BY
clauseORDER BY expression [ASC|DESC] [, expression [ASC|DESC]] ...
SELECT productName, listPrice, discountPercent FROM products WHERE listPrice < 500 ORDER BY productName;
SELECT productName, listPrice, discountPercent FROM products WHERE listPrice < 500 ORDER BY listPrice DESC;
SELECT productName, listPrice, discountPercent FROM products WHERE categoryID = 1 ORDER BY discountPercent, listPrice DESC;
ORDER BY
clause specifies how you want the rows in the result set sorted. You can sort by one or more columns, and you can sort each column in either ascending (ASC
) or descending (DESC
) sequence. ASC
is the default.