SELECT a.产品编号,a.产品描述,a.期初库存+NVL(b.数量,0)-NVL(c.数量,0) as 当前库存 ;
FROM 产品信息表 as a ;
LEFT JOIN (select 产品编号,SUM(数量) as 数量 FROM 入库信息表 GROUP BY 产品编号) as b ON a.产品编号=b.产品编号 ;
LEFT JOIN (select 产品编号,SUM(数量) as 数量 FROM 出库信息表 GROUP BY 产品编号) as c ON a.产品编号=c.产品编号