Organize Output I: Use the Order By Clause
Just as you will always use the Where clause to filter irrelevant data, you will always use the Order By clause to sort the data in your resultset. Furthermore, based on the fields you choose to sort the data, you will want to sort the data ascending, descending, or some combination thereof. All of these operations are accomplished with the Order By clause. To illustrate how the Order By clause works, consider the following code:
SELECT lastname + ", " + firstname As client From Client Where ClientType = "I" Order By lastname
Figure 8.13 illustrates the results of this query.
Figure 8.13. The Order By clause allows you to sort the data in your resultset.
By default, any field you select to order ...
Get Absolute Beginner’s Guide to Databases now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.