Descending Order

To sort from the largest value to the smallest, write DESC after the column. It's short for descending:

SELECT title, released
FROM games
ORDER BY released DESC;
titlereleased
Knight's Oath2025-11-14
Goal Rush2025-09-26
Turbo Karts2025-06-05
Star Pilots2025-01-23
……

Now the newest games come first. Descending order turns everything around: the largest numbers first, text from Z to A, the latest dates first, and the rows with NULL at the very end. Here, those are Robot Rebellion and Mystery Manor, which haven't come out yet.

The opposite of DESC is ASC, ascending. It's the default, so ORDER BY released ASC is the same as ORDER BY released. You don't have to write it, but sometimes it makes a query clearer: whoever reads it sees that you wanted ascending order on purpose.

DESC comes in handy whenever you want “the most” of something at the top: the most expensive games, the newest orders, the best reviews. In the next exercises, you'll combine it with sorting by several columns and with showing just the first few rows.

Typical mistake: DESC in front of the column. It belongs after the column it sorts, so this query ends with an error:

SELECT title, price
FROM games
ORDER BY DESC price;
Error on line 1: near "price": syntax error

Instructions

The query in the editor sorts the games from the cheapest. Change it, so that the most expensive games come first:

titleprice
Knight's Oath60
Goal Rush50
Ice Hockey Pro45
……

Below it, add a query that shows the name of every customer and the day they joined (joined), with the customers who joined last at the top:

namejoined
Max Baker2025-10-03
Sophie Adams2025-08-21
Henry Scott2025-05-06
……

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

2/9