DESC is the companion to ASC in the ORDER BY clause. When applied to a column, expression, or ordinal position in ORDER BY, it instructs the database engine to return rows with the highest values first. If multiple columns are listed, each DESC or ASC modifier affects only the column that precedes it. When no modifier is supplied, most dialects default to ASC (ascending). DESC applies after the result set is filtered (WHERE), grouped (GROUP BY), and projected (SELECT) but before pagination (LIMIT, OFFSET, FETCH FIRST) is evaluated. Handling of NULL values differs by dialect: PostgreSQL and Oracle allow explicit NULLS FIRST or NULLS LAST, while MySQL orders NULLs first in DESC by default. DESC is a keyword, not a standalone statement, and should not be confused with DESCRIBE, the MySQL shorthand for SHOW COLUMNS.
ORDER BY, ASC, NULLS FIRST, NULLS LAST, LIMIT, FETCH FIRST
SQL-92
DESC means descending. The database returns the highest values first for the specified column or expression.
No. DESC only affects the final ordering of rows. WHERE, GROUP BY, and HAVING are processed first.
Yes. Add DESC or ASC after each column as needed. Each modifier affects only the column directly before it.
In PostgreSQL or Oracle append NULLS LAST. In SQL Server use ORDER BY CASE WHEN col IS NULL THEN 1 ELSE 0 END, col DESC. MySQL does this automatically.