W
wisdomphg
Unregistered / Unconfirmed
GUEST, unregistred user!
SELECT p1.*, (P1.Qty1+ P1.Qty2 + P1.Qty3 + P1.Qty4) AS 合计from(select a.DINGD_NO as '生产编号',a.ehw_pici as '生产批次',a.ehw_xiadate as '下单日期',a.ehw_xiaqty as '下单数量',a.ehw_zgs as '个取数',SUM(CASE A.GONGX_NO WHEN '辅料' THEN (A.EHW_INQTY-A.EHW_OUTQTY) ELSE 0 END) as qty1,SUM(CASE A.GONGX_NO WHEN '领料' THEN (A.EHW_INQTY-A.EHW_OUTQTY) ELSE 0 END) as qty2,SUM(CASE A.GONGX_NO WHEN '钻孔' THEN (A.EHW_INQTY-A.EHW_OUTQTY) ELSE 0 END) as qty3,SUM(CASE A.GONGX_NO WHEN '镀铜' THEN (A.EHW_INQTY-A.EHW_OUTQTY) ELSE 0 END) as qty4,SUM(CASE A.GONGX_NO WHEN '露光' THEN (A.EHW_INQTY-A.EHW_OUTQTY) ELSE 0 END) as qty5,SUM(CASE A.GONGX_NO WHEN '蚀刻' THEN (A.EHW_INQTY-A.EHW_OUTQTY) ELSE 0 END) as qty6FROM EHW A GROUP BY a.DINGD_NO,a.ehw_pici,a.ehw_xiadate,a.ehw_xiaqty,a.ehw_zgs) as p1where (P1.Qty1+ P1.Qty2 + P1.Qty3 + P1.Qty4) <> 0以上查出的记录不会按a.dingd_no字段从A到B排列?