Datasheet

Writing Simple Queries
41
Nancy 17-AUG-94 12000 101
Daniel 16-AUG-94 9000 108
John 28-SEP-97 8200 108
Ismael 30-SEP-97 7700 108
Jose Manuel 07-MAR-98 7800 108
Luis 07-DEC-99 6900 108
William 07-JUN-94 8300 205
8 rows selected.
The ORDER BY clause cannot have more than 255 columns or expressions.
Sorting NULLs
By default, in an ascending-order sort, the NULL values appear at the bottom of the result set;
that is,
NULLs are sorted higher. For descending-order sorts, NULL values appear at the top
of the result setagain,
NULL values are sorted higher. You can change the default behavior
by using the
NULLS FIRST or NULLS LAST keyword, along with the column names (or alias
names or positions). The following examples demonstrate how to use
NULLS FIRST in an
ascending sort:
SELECT last_name, commission_pct
FROM employees
WHERE last_name LIKE ‘R%’
ORDER BY commission_pct ASC, last_name DESC;
LAST_NAME COMMISSION_PCT
------------------------- --------------
Russell .4
Rogers
Raphaely
Rajs
SELECT last_name, commission_pct
FROM employees
WHERE last_name LIKE ‘R%’
ORDER BY commission_pct ASC NULLS FIRST, last_name DESC;
95127c01.indd 41 2/18/09 6:37:10 AM