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
posted @ 2023-02-28 16:50  ttttttian  阅读(478)  评论(0)    收藏  举报