Oracle order by子句对NULL的排序

2、测试order by

看到不同的排序方式,NULL值所排序的位置不同。升序(asc)NULL排在最后,降序(desc)NULL排在最前。
我们再来看看官方文档是怎么描述的
ASC | DESC Specify the ordering sequence (ascending or descending). ASC is the default.
NULLS FIRST | NULLS LAST Specify whether returned rows containing nulls should appear first or last in the ordering sequence.
NULLS LAST is the default for ascending order, and NULLS FIRST is the default for descending order.
可以看到我们的实验结果与官方文档描述是一致的。而且还可以使用NULLS FIRST|NULLS LAST来决定NULL的值是排在最前还是排在最后。

猜你喜欢

转载自www.linuxidc.com/Linux/2017-01/139782.htm