SELECT 产品.产品编号, 产品.产品描述, 产品.进货价格, 产品.统一售价, Sum(nz([进货表].[进货数量])) AS 进货数量, Sum(nz([销售表].[销售数量])) AS 销售数量, Sum(nz([进货表].[进货数量]))-Sum(nz([销售表].[销售数量])) AS 当前库存
FROM (产品 LEFT JOIN 进货表 ON 产品.产品编号 = 进货表.产品编号) LEFT JOIN 销售表 ON 产品.产品编号 = 销售表.产品编号
GROUP BY 产品.产品编号, 产品.产品描述, 产品.进货价格, 产品.统一售价;
SELECT 产品.产品编号, 产品.产品描述, 产品.进货价格, 产品.统一售价, IM.进货合计, EX.销售合计, IM.进货合计-EX.销售合计 AS 当前库存
FROM (产品 LEFT JOIN [SELECT 产品编号,Nz(Sum(进货表.进货数量),0) AS 进货合计 FROM 进货表 GROUP BY 产品编号]. AS IM ON 产品.产品编号=IM.产品编号) LEFT JOIN [SELECT 产品编号, Nz(Sum(销售表.销售数量),0) AS 销售合计 FROM 销售表 GROUP BY 产品编号]. AS EX ON 产品.产品编号=EX.产品编号
GROUP BY 产品.产品编号, 产品.产品描述, 产品.进货价格, 产品.统一售价, IM.进货合计, EX.销售合计;