In chapter 3, I noted that your relational database management system (RDBMS) won’t return results in a predictable order. This is by design, as any given request may or may not need the data to be ordered, and the RDBMS is simply taking the most efficient way of returning the data requested. The results may appear in some sort of order, such as the order in which the rows were added to a table, but there are no implicit guarantees about how the data in the results of a query will be ordered. If we want to be certain of the order of results, we need to say so explicitly in our SQL query.
Some fun features associated with ordering data allow us to manipulate the number of rows returned in our result set. These features can be useful if we have millions or billions of rows and need to see only the most recent entries or the entries with the smallest or largest values.
Because you’re just starting to write SQL, this chapter also discusses how to use comments in SQL. Comments are indispensable tools for you and anyone else who may read your SQL, and if you’re going to write queries properly, you should start building the habit of using comments today.