SELECT le.equipcode,sum(case when wo.ordertype=0 then 1 else 0 END) as wxcount,sum(case when wo.ordertype=0 then wo.workcost else 0 END) as wxcost ,
sum(case when wo.ordertype=1 then 1 else 0 END) as yhcount,sum(case when wo.ordertype=1 then wo.workcost else 0 END)as yhcost
FROM LAYOUT_EQUIP le LEFT JOIN WORK_ORDER wo ON le.equipcode=wo.equipcode
WHERE
le.del_flag = 0 and wo.del_flag=0
group by le.equipcode
同一个表两个条件的统计
posted on 2018-08-29 16:26  一抹书香  阅读(142)  评论(0编辑  收藏  举报