Sorting Query Results: ORDER BY

The ORDER BY clause can make your results more readable. It allows you to sort by any expression or mixture of expressions in the SELECT list—from simple columns to more complex combinations of column names, functions, mathematical computations, strings, or display labels. Each sort can be in ascending or descending order. (See “Sort Up, Sort Down” later in this chapter for details.)

Get Practical SQL Handbook, The: Using SQL Variants, Fourth 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.