Access多个表查询汇总结果怎么不对呀,求高手指点!
如图:SQL代码如下:SELECT销售明细.年,销售明细.月,销售明细.代码,Sum(销售明细.销售量)AS销售合计,Sum(调入明细.数量)AS调入合计,Sum(调出明...
如图:
SQL代码如下:
SELECT 销售明细.年, 销售明细.月, 销售明细.代码, Sum(销售明细.销售量) AS 销售合计, Sum(调入明细.数量) AS 调入合计, Sum(调出明细.数量) AS 调出合计FROM (销售明细 LEFT JOIN 调入明细 ON (销售明细.月 = 调入明细.月) AND (销售明细.年 = 调入明细.年) AND (销售明细.代码 = 调入明细.代码)) LEFT JOIN 调出明细 ON (销售明细.月 = 调出明细.月) AND (销售明细.年 = 调出明细.年) AND (销售明细.代码 = 调出明细.代码)GROUP BY 销售明细.年, 销售明细.月, 销售明细.代码; 展开
SQL代码如下:
SELECT 销售明细.年, 销售明细.月, 销售明细.代码, Sum(销售明细.销售量) AS 销售合计, Sum(调入明细.数量) AS 调入合计, Sum(调出明细.数量) AS 调出合计FROM (销售明细 LEFT JOIN 调入明细 ON (销售明细.月 = 调入明细.月) AND (销售明细.年 = 调入明细.年) AND (销售明细.代码 = 调入明细.代码)) LEFT JOIN 调出明细 ON (销售明细.月 = 调出明细.月) AND (销售明细.年 = 调出明细.年) AND (销售明细.代码 = 调出明细.代码)GROUP BY 销售明细.年, 销售明细.月, 销售明细.代码; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询