Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Text information
Boolean
Date and time
Summary

Instruction

That's right. We've already mentioned that one of the reasons for data types is that we can sort information if we know what they are. Let's check that.

SELECT * FROM user_account
ORDER BY nickname;

As you can see, we can sort the results of our SELECT statement by writing ORDER BY followed by the name of the column (or a few columns separated with commas). The default order is ascending (that is, A comes before B). If you want to reverse the order, just put DESC after the name of the column:

SELECT *
FROM user_account
ORDER BY nickname DESC; 

Exercise

Peter started working on his database and he he now has an impressive number of two columns in his table user_account: columns first_name and nickname.

Let's retrieve all information from the table and sort it according to the values in column first_name in the ascending order.

Stuck? Here's a hint!

Type

SELECT *
FROM user_account
ORDER BY first_name;