ORDER BY DESC in SQL

Level 246 keystrokes

DESC keyword sorts the result in descending order.

SQL code

-- Returns the name and age columns of users
-- ORDER BY age DESC sorts from the highest age to the lowest
1SELECT name, age FROM users ORDER BY age DESC;

Output

+-------+-----+
| name  | age |
+-------+-----+
| Carol |  35 |
| Bob   |  30 |
| Alice |  25 |
+-------+-----+
3 rows in set
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this SQL code and how often they appear.

  • ,× 1
  • ;× 1

More SQL examples at level 2

← SQL typing practice