原
select a.item_no,(a.qty+case b.qty when null then 0 else sum(b.io*b.qty) end )as 月底庫存數量
from itmmbemt a left join itmmsum b on a.item_no=b.item_no and a.YYYYMM=b.YYYYmm
where a.YYYYMM='201206' and a.item_no='10010014'
group by a.item_no,a.qty,b.qty
修
select a.item_no,(a.qty+case when b.qty is null then 0 else sum(b.io*b.qty) end )as 月底庫存數量
from itmmbemt a left join itmmsum b on a.item_no=b.item_no and a.YYYYMM=b.YYYYmm
where a.YYYYMM='201206' and a.item_no='10010014'
group by a.item_no,a.qty,b.qty
0 意見:
張貼留言