Sorts
In Firebird 2, NULL
s are considered “smaller” than anything else when it comes to sorting.Consequently, they come first in ascending sorts and last in descending sorts.You can override this default placement by adding a NULLS FIRST
or NULLS LAST
directive to the ORDER BY
clause.
In earlier versions, NULL
s were always placed at the end of a sorted set, no matter whether the order was ascending or descending.For Firebird 1.0, that was the end of the story: NULL
s would always come last in any sorted set, period.Firebird 1.5 introduced the NULLS FIRST/LAST
syntax, so you could force them to the top or bottom.
To sum it all up:
Ordering |
|
||
---|---|---|---|
Firebird 1 |
Firebird 1.5 |
Firebird 2 |
|
|
bottom |
bottom |
top |
|
bottom |
bottom |
bottom |
|
— |
top |
top |
|
— |
bottom |
bottom |
Specifying NULLS FIRST
on an ascending or NULLS LAST
on a descending sort in Firebird 2 is of course rather pointless, but perfectly legal.The same is true for NULLS LAST
on any sort in Firebird 1.5.
Note
|
|
Warning
|
Don’t be tempted into thinking that, because |