When Oracle order by is sorted, null values are ranked first (nulls first)

Article Directory

in conclusion

  • Use keywords nulls first/lastto treatment.
    • nulls first: The record representing the null value will be ranked first (whether it is asc or desc)
    • nulls last: The record representing the null value will be ranked last (whether it is asc or desc)
SELECT t.* FROM scott.emp t ORDER BY t.comm NULLS FIRST; -- null 值在最前面
SELECT t.* FROM scott.emp t ORDER BY t.comm NULLS LAST; -- null 值在最后面

Please note

Default:, null 默认为最大值 namely:

  • Asc (ascending order), it is ranked last
  • In desc (descending order), rank first

Guess you like

Origin blog.csdn.net/qq_34745941/article/details/107219551