2.5 处理排序空值
Q: 指定是否将空值字段行排在最后
A: 使用 case 表达式在 order by 子句中增加标记列; 或 RDBMS 特殊方案
DB2, MySQL, PostgreSQL, SQL Server, Oracle
/* all nulls last */
select ename, sal, comm, is_null
from (
select ename, sal, comm,
case when comm is null then 0 else 1 end as is_null
from emp
) x
order by is_null desc, comm
…