select MACHINE, P_LOT_NO, sum(input_qty) from ( SELECT FS_PLATING.MACHINE, FS_PLATING.P_LOT_NO, JOB_ORD.STOCK_CODE, STOCK_MST.DESCRIPTION , case when split_qty>0 then split_qty else qty end as 'input qty' FROM FS_PLATING LEFT OUTER JOIN JOB_ORD ON FS_PLATING.P_LOT_NO = JOB_ORD.P_LOT_NO, STOCK_MST WHERE ( JOB_ORD.stock_CODE = STOCK_MST.stock_CODE ) and ptf_date>='2002-7-4 0:00:00' ) as A group by MACHINE, P_LOT_NO order by MACHINE, P_LOT_NO
我是想得到一段时间里每台machine里每一个p_lot_no里先按p_lot_no里的input_qty
求和,再按machine 求和
怎样才行?
请赐教
SELECT FS_PLATING.MACHINE,
FS_PLATING.P_LOT_NO,
JOB_ORD.STOCK_CODE,
STOCK_MST.DESCRIPTION ,
case
when split_qty>0 then split_qty else qty end as 'input qty'
FROM FS_PLATING LEFT OUTER JOIN JOB_ORD ON FS_PLATING.P_LOT_NO = JOB_ORD.P_LOT_NO,
STOCK_MST
WHERE ( JOB_ORD.stock_CODE = STOCK_MST.stock_CODE ) and ptf_date>='2002-7-4 0:00:00'
) as A
group by MACHINE, P_LOT_NO
order by MACHINE, P_LOT_NO