5
Sorting Data
Keywords Introduced
ORDER BY • ASC • DESC
The ability to present data in a sorted order is often essential to the task at hand. For example, if an analyst is shown a large list of customers in a random order, they’d probably find it difficult to locate one individual customer. However, if the same list is sorted alphabetically, the desired customer can quickly be located.
The idea of sorting data applies to many situations, even when the data isn’t alphabetic in nature. For example, you can sort orders by order date, allowing you to rapidly find an order taken at a particular date and time. Alternatively, you can sort orders by the order amount, allowing you to view from the smallest to largest. No matter what form a sort takes, ...
Get The Language of SQL, 3rd Edition 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.