SELECT a.产品编码, a.产品名称, a.入库数量, b.出库数量, c.盘盈, a.入库数量-b.出库数量+c.盘盈 AS 结存数量
FROM ([SELECT 入库.产品编码, 入库.产品名称, Sum(入库.入库数量) AS 入库数量 FROM 入库 GROUP BY 入库.产品编码, 入库.产品名称]. AS a INNER JOIN [SELECT 出库.产品编码, Sum(出库.出库数量) AS 出库数量 FROM 出库 GROUP BY 出库.产品编码]. AS b ON a.产品编码 = b.产品编码) INNER JOIN [SELECT 盈亏表.产品编码, 盈亏表.盘盈 FROM 盈亏表]. AS c ON b.产品编码 = c.产品编码;