CodingDatabases One can use the ORDER BY clause in a query to sort rows based on a specified column with the default ordering being increasing. To sort in descending order one uses the DESC keyword. One can also sort by multiple columns by listing them in order of priority. A generic query might look like

SELECT column FROM table
ORDER BY orderby_column1 [DESC], orderby_column2 [DESC], ..., orderby_columnN [DESC] 

One can also order by the queried columns, specifying each by their index in the order provided:

SELECT column1, column2, ..., columnN FROM table
ORDER BY 1 [DESC], 3 [DESC] 

which would order the output first by column1 and subsequently by column3.