sql 开窗函数排序遇到空值的处理办法
sql sever默认null最小
升序排序
null值在最前面,若要放在后面,则:
order by case when col is null then 1 else 0 end, col
降序排序
null值在最后面,若要放在前面,则:
order by case when col is null then 0 else 1 end, col desc
sql sever默认null最小
null值在最前面,若要放在后面,则:
order by case when col is null then 1 else 0 end, col
null值在最后面,若要放在前面,则:
order by case when col is null then 0 else 1 end, col desc