Progress
Embedded SQL-92
Guide and Reference


NULL Values in an ORDER BY Clause

When you apply an ORDER BY clause to a column containing NULL values, the NULL value is treated as being greater than any non-NULL value. When the ordering is ascending, the NULL values sort at the end. When the ordering is descending, the NULL values sort first.

EXAMPLE

The following example shows the selection of employees (ename) ordered by the project numbers (projno). The ORDER BY clause specifies descending (DESC). The employees not assigned to a project are reported first, and those with the highest project numbers are reported last:

EXEC SQL
     SELECT ename, deptno FROM employee
     ORDER BY projno DESC ; 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095