On January 21th at 14:15 UTC , progression through exercises will be unavailable for 10 minutes due to a planned maintenance break.
Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
6. Sort by a few columns
Eliminating duplicate results
HAVING: filtering and ordering groups
Let's practice


Good job. All right, one more thing before we move on: you can sort your results by more than one column and each of them can be sorted in a different order:

FROM order
ORDER BY customer_id ASC, total_sum DESC;

As you can see, the results will first be sorted by customer_id in the ascending order (lowest values first) and then, for each customer_id, the orders will be sorted by the total_sum in the descending order (greatest values first).


Select all rows from the table employees and sort them in the ascending order by the department and then in the descending order by the salary.

Stuck? Here's a hint!


FROM employees
ORDER BY department ASC, salary DESC;