SQL Serve数据库排序空值null始终前置的方法
【转:http://blog.knowsky.com/233986.htm】
【sqlserver】:
sqlserver 认为 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
[转载请保留作者信息 作者:冯天文 ]
 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号