oracle排序的时候默认空值是最大的,如果想要自己规定空值显示的位置,可以使用关键字NULLS FIRST和NULLS LAST。
创建测试用表:
CREATE OR REPLACE VIEW v ASSELECT 1 AS c FROM DUALUNION ALLSELECT NULL AS c FROM DUALUNION ALLSELECT 3 AS c FROM DUAL;SELECT * FROM v;
空值在前:
SELECT * FROM v ORDER BY c NULLS FIRST;
空值在后:
SELECT * FROM v ORDER BY c DESC NULLS LAST;