ORDER BY clause to order the results that are returned from a SELECT
statement. You can specify just a column or use any expression with functions. If you are
GROUP BY clause, you can use grouping functions in
Ordering is done after grouping.
You can use multiple ordering expressions, separated by commas. Rows will be sorted by the first expression, then by the second expression if they have the same value for the first, and so on.
You can use the keywords
DESC after each ordering expression to
force that ordering to be ascending or descending, respectively. Ordering is ascending
You can also use a single integer as the ordering expression. If you use an integer n, the results will be ordered by the nth column in the select expression.
MariaDB starting with 5.5.35
Starting from MariaDB 5.5.35 duplicated entries in the
ORDER BY clause are removed. MySQL 5.6 also removes duplicated fields.