本文主要是介绍nulls first 或 nulls last,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
#原数据
select * from jinbo.tel_info;person | day | recevice | miss
--------+------------+----------+------A | 2018-01-18 | 10 | 0B | 2018-01-18 | 0 | 5C | 2018-01-18 | 4 | 4D | 2018-01-18 | 0 | 0E | 2018-08-27 | 2 |
(5 rows)# asc 的时候默认把null 后排, 相当于 order by miss asc nulls last
select * from jinbo.tel_info order by miss asc;person | day | recevice | miss
--------+------------+----------+------A | 2018-01-18 | 10 | 0D | 2018-01-18 | 0 | 0C | 2018-01-18 | 4 | 4B | 2018-01-18 | 0 | 5E | 2018-08-27 | 2 |
(5 rows)# asc nulls first
select * from jinbo.tel_info order by miss asc nulls first;person | day | recevice | miss
--------+------------+----------+------E | 2018-08-27 | 2 | A | 2018-01-18 | 10 | 0D | 2018-01-18 | 0 | 0C | 2018-01-18 | 4 | 4B | 2018-01-18 | 0 | 5
(5 rows)#asc 的时候默认把null 前排, 相当于 order by miss asc nulls first
select * from jinbo.tel_info order by miss desc;person | day | recevice | miss
--------+------------+----------+------E | 2018-08-27 | 2 | B | 2018-01-18 | 0 | 5C | 2018-01-18 | 4 | 4A | 2018-01-18 | 10 | 0D | 2018-01-18 | 0 | 0#desc nulls last
select * from jinbo.tel_info order by miss desc nulls last;person | day | recevice | miss
--------+------------+----------+------B | 2018-01-18 | 0 | 5C | 2018-01-18 | 4 | 4A | 2018-01-18 | 10 | 0D | 2018-01-18 | 0 | 0E | 2018-08-27 | 2 |
(5 rows)
这篇关于nulls first 或 nulls last的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!