SQL ORDER BY: Sorting Data Guide
In SQL, the ORDER BY clause can be used to specify the sorting rules. This clause is used to sort the query results by the values of one or more columns in ascending or descending order.
Here is an example:
SELECT column1, column2
FROM table_name
ORDER BY column1 ASC, column2 DESC;
In the example above, the ORDER BY clause specifies to sort in ascending order according to the values of column1, and then in descending order by the values of column2 when the values of column1 are the same.
ASC keyword is used to indicate ascending order, while DESC keyword is used to indicate descending order. If no sorting rule is specified, the default is ascending order.