Database Reference
In-Depth Information
ORDER BY (optional)
. Add sorting parameters, allowing rows to be
rearranged in a specified order.
Sorting query results helps make your report more readable and useful.
For example, it is very useful to list people in alphabetical order by last
name. The ORDER BY clause of the SELECT statement provides sorting
capability.
You can sort by any column or expression you use in your SELECT
clause. In addition, you can sort by any column in the table (or any expres-
sion based on any column) you are querying, even if the column is not
selected. You can sort by up to 255 columns or expressions in one SELECT
statement.
The ORDER BY clause appears after the WHERE clause. Figure 6.1
shows the syntax with comments explaining the parts.
Note:
The ORDER BY clause is an optional clause, as is the WHERE
clause. You can have an ORDER BY clause without a WHERE clause and
vice versa.
Figure 6.1
The SELECT
Statement
Optional ORDER
BY Clause.
Search WWH ::




Custom Search