Loading lesson path
Formula
keyword is used to sort the result - set in ascending or descending order.Formula
keyword sorts the result - set in ascending order(ASC) by default.
Sort the products from lowest to highest price:
SELECT * FROM Products
ORDER BY Price;column1, column2, ...
table_name
column1, column2, ...
ASC|DESC;Products table used in the examples:
10 boxes x 20 bags 18
Formula
24 - 12 oz bottles19
Formula
12 - 550 ml bottles10
Formula
48 - 6 oz jars22
36 boxes 21.35
To sort the records in descending order, use the DESC keyword.
Sort the products from highest to lowest price:
SELECT * FROM Products
ORDER BY Price DESC;For string values, the ORDER BY keyword will sort the values in the column alphabetically: