sql语句技巧
1人赞赏了该文章
2,290次浏览
编辑于2015年09月10日 10:58:20
在报表中我们经常会需要进行各种状态的单据统计。这里举一下统计订单的方法。如:订单状态字段为orderstatus,值分别为1已提交,2已付款,3已出库
sql语句可以这样写
select sum(case when orderstatus==1 then 1 else 0) as bill_submited,
sum(case when orderstatus==2 then 1 else 0) as bill_payed,
sum(case when orderstatus==3 then 1 else 0) as bill_delivery
from t_order
推荐阅读