对oracle空值排序,最前面(nulls first)或者最后面函(nulls last)

来源:互联网 发布:python 伯乐在线 编辑:程序博客网 时间:2024/06/05 23:17

nulls first/last 可以对查询后的数据依据空值和非空值进行排序,可以结合业务需要与正序asc 和 倒叙 desc 结合。

1,排在最前面用order by collums_name [asc] nulls first

  select t.name,t.code from table t where  1=1 order by name [asc] nulls first;


namecode9078 9078 9078 90780.426990780.51590780.687

2,排在最后面order by name [desc] nulls last

  select t.name,t.code from table t where t.code!='1' order by name  [desc] nulls last;

namecode90780.68790780.51590780.42699078 9078 9078 

阅读全文
0 0
原创粉丝点击