风雨雷电是
幼苗
共回答了18个问题采纳率:83.3% 举报
select GoodName as 物品,sum(Qty) as 进货数量 from GoodDtl where Cls = '进' group by GoodName; --tab1
select GoodName as 物品,sum(Qty) as 出货数量 from GoodDtl where Cls = '出' group by GoodName;--tab2
select 物品,tab1. 进货数量,tab2.出货数量,tab1. 进货数量-tab2.出货数量 as 当前库存
from
(select GoodName as 物品,sum(Qty) as 进货数量 from GoodDtl where Cls = '进' group by GoodName) tab1,
(select GoodName as 物品,sum(Qty) as 出货数量 from GoodDtl where Cls = '出' group by GoodName) tab2
where tab1.物品 = tab2.物品;
1年前
10