什么时候在订购查询降序或升序时首先要NULLS?
在我看来,绝大多数时间,无论排序升序还是下降,期望的行为将是最后的.相反,我们应该首先指定NULLS FIRST.
实际上,使用默认排序顺序(ASCENDING)NULL值最后.
逻辑指示排序顺序与DESCENDING关键字相反,因此在这种情况下先排序NULL.
但最好的部分是最后的:你可以选择你想要的方式:
> Use the NULLS FIRST | LAST
clause.
引用current manual,版本9.3作为写作:
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 is
NULLS 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.
大胆强调我的