SQL DESC Keyword
The DESC command is used to sort the data returned in descending order. It is used with the ORDER BY clause to reverse the natural order of the data such as Z to A for text or highest to lowest for numbers.
SQL DESC Syntax
SQL
x
1
SELECT column1, column2, ...
2
FROM table_name
3
ORDER BY column_name DESC;
SQL DESC Example
The following SQL statement selects all the columns from the Patients
table, sorted in descending order by the last_name
column, This will return all patients sorted from Z to A by their last name:
SQL
1
1
SELECT * FROM Patients
2
ORDER BY last_name DESC;
