SELECT DISTINCTROW Format$([产品库存].[日期],'YYYY年mM月') AS [日期 按月], 产品库存.产品, Sum(产品库存.入库) AS 入库1, Sum(产品库存.出库) AS 出库1, Sum(产品库存.赠送) AS 赠送1, SUM(入库)-SUM(出库)-SUM(赠送) AS 库存
FROM 产品库存
GROUP BY Format$([产品库存].[日期],'yyyy年MM月'), 产品库存.产品, Year([产品库存].[日期])*12+DatePart('m',[产品库存].[日期])-1;