Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
SQL Basics
Summary

Instruction

Good job. Finally, we can sort rows by multiple columns. Take a look:

SELECT *
FROM employee
ORDER BY department ASC, level DESC;

In the query above, we first sort all employees by the department in the ascending order, and then by the level in the descending order. As we mentioned before, rows are sorted in the ascending order by default, so the keyword ASC after the department column is not required – we only added it for clarity.

Exercise

The German couple loves big hotels, remember? Now, show the columns name, city and room_count from the hotel table. Sort the results first by the city in the ascending order, and then by the room_count in the descending order.

Stuck? Here's a hint!

Type:

SELECT name, city, room_count
FROM hotel
ORDER BY city ASC, room_count DESC;