如图:
SQL代码如下:
SELECT 销售明细.年, 销售明细.月, 销售明细.代码, Sum(销售明细.销售量) AS 销售合计, Sum(调入明细.数量) AS 调入合计, Sum(调出明细.数量) AS 调出合计FROM (销售明细 LEFT JOIN 调入明细 ON (销售明细.月 = 调入明细.月) AND (销售明细.年 = 调入明细.年) AND (销售明细.代码 = 调入明细.代码)) LEFT JOIN 调出明细 ON (销售明细.月 = 调出明细.月) AND (销售明细.年 = 调出明细.年) AND (销售明细.代码 = 调出明细.代码)GROUP BY 销售明细.年, 销售明细.月, 销售明细.代码;