SQL ORDER BY 排序
当一个物料表中有物料编码和数量时,我们需要将数量为0的放在最后,然后数量大于0的按物料编码排序
select new_partcode,new_siteinvqty from new_srv_sitelocationinv
order by case new_siteinvqty when '0' then '0' else '1' end desc,new_partcode asc
物料编码 数量
1101-03123   2
1101-03707   2
1104-00975   3
1104-00975   2
1104-01061   3
9601-14733   0
9601-14764   0
9601-17101   0
 
                    
                 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号