加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

为什么在PostgreSQL查询中订购DESC时,NULL值先出现?

发布时间:2020-12-13 16:32:18 所属栏目:百科 来源:网络整理
导读:什么时候在订购查询降序或升序时首先要NULLS? 在我看来,绝大多数时间,无论排序升序还是下降,期望的行为将是最后的.相反,我们应该首先指定NULLS FIRST. 实际上,使用默认排序顺序(ASCENDING)NULL值最后. 逻辑指示排序顺序与DESCENDING关键字相反,因此在这种情
什么时候在订购查询降序或升序时首先要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; if NULLS FIRST is specified,null values sort before all
non-null values. If neither is specified,the default behavior is
NULLS LAST when ASC is specified or implied
,and NULLS FIRST when DESC
is specified (thus,the default is to act as though nulls are larger
than non-nulls). When USING is specified,the default nulls ordering
depends on whether the operator is a less-than or greater-than operator.

大胆强调我的

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读