木棉

导航

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

posted on 2012-04-19 14:05  木棉  阅读(226)  评论(0编辑  收藏  举报