
在我看来,绝大多数时间,无论排序升序还是下降,期望的行为将是最后的.相反,我们应该首先指定NulLS FirsT.
实际上,使用默认排序顺序(ASCENDING)NulL值最后.逻辑指示排序顺序与DESCENDING关键字相反,因此在这种情况下先排序NulL.
但最好的部分是最后的:你可以选择你想要的方式:
> Use the NULLS FIRST | LAST clause.
引用current manual,版本9.3作为写作:
If
NulLS LASTis specifIEd,null values sort after all non-null
values; ifNulLS FirsTis specifIEd,null values sort before all
non-null values. If neither is specifIEd,the default behavior is
NulLS LASTwhenASCis specifIEd or implIEd,andNulLS FirsTwhenDESC
is specifIEd (thus,the default is to act as though nulls are larger
than non-nulls). WhenUSINGis specifIEd,the default nulls ordering
depends on whether the operator is a less-than or greater-than operator.
大胆强调我的
总结以上是内存溢出为你收集整理的为什么在PostgreSQL查询中订购DESC时,NULL值先出现?全部内容,希望文章能够帮你解决为什么在PostgreSQL查询中订购DESC时,NULL值先出现?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)