When would you ever want NULLS first when ordering a query descending or ascending?
In my opinion, the vast majority of the time the desired behavior whether sorting ascending or descending would be NULLS LAST. Instead, we should have to specify NULLS FIRST.
Actually, with default sort order (ASCENDING
) NULL values come last.
Logic dictates that the sort order be reversed with the DESCENDING
keyword, so nulls come first in this case.
But you can choose which way you want it. See:
If
NULLS LAST
is specified, null values sort after all non-null values; ifNULLS FIRST
is specified, null values sort before all non-null values. If neither is specified, the default behavior isNULLS LAST
whenASC
is specified or implied, andNULLS FIRST
whenDESC
is specified (thus, the default is to act as though nulls are larger than non-nulls). WhenUSING
is specified, the default nulls ordering depends on whether the operator is a less-than or greater-than operator.
Bold emphasis mine.