SQL = "Select 物品名称,库存数量-出库数量 as 库存数量 from (Select 物品名称,库存数量,IIF(出库数量 is Null,0,出库数量) as 出库数量 from (Select A.*,B.出库数量 from (Select * from 库存) as A left join (Select 物品名称,sum(出库数量) as 出库数量 from 出库明细 Group By 物品名称) as B on A.物品名称=B.物品名称))"
执行SQL,就可以得到库存了