ORDER BY

ORDER BY sorts the result by one or more columns or expressions, in ASC (default) or DESC. Without it, row order is not guaranteed. It runs near the end of the query, after SELECT, and can therefore use aliases.

Example

SELECT nom, prix FROM produits ORDER BY prix DESC, nom;

Related concepts

The whole glossary