End of Summer - hours only!Up to 80% off on all courses and bundles.-Close
5. Ascending and descending orders
Eliminating duplicate results
HAVING: filtering and ordering groups
Let's practice


Good. As you can see, the lowest salary was shown first and the highest salary last. This ascending order of results is performed in SQL by default. If you want to be precise and make things clear, however, you can use the keyword ASC (short for the ascending order) after the column name:

FROM orders
ORDER BY total_sum ASC;

Adding the keyword ASC will change nothing, but it will show your intention in a very clear way.

We can also reverse the order and make the greatest values appear first.

FROM orders
ORDER BY total_sum DESC;

As you can see, we've added the word DESC after the column name, which is short for the descending order. As a result, the highest values in the column total_sum will be shown first.


Select all rows from the table employees and sort them in the descending order by the column last_name.

Stuck? Here's a hint!


FROM employees
ORDER BY last_name DESC;