MS-访问101 - 总和表达式作为聚合函数的一部分

时间:2018-03-28 09:10:23

标签: sql ms-access-2013

我刚刚切换回MS Access(在Excel VBA上工作了一年),我的SQL有点生锈......我收到错误

  

您尝试执行不包含指定的查询   表达式(下面的总和)作为聚合函数的pat

来自此代码:

SELECT 
    FYF.ACNT_CODE, 
    FYF.[Team code], 
    Sum([FYF]![Value])*(1+[IncreaseAssumptions]![Amount]) AS [Year 1 Cost] 
INTO [Year 1 costs]
FROM FYF 
INNER JOIN 
    (SunAccounts INNER JOIN IncreaseAssumptions ON SunAccounts.IncreaseType = IncreaseAssumptions.IncreaseType) 
    ON FYF.ACNT_CODE = SunAccounts.Account_Code
WHERE (((IncreaseAssumptions.YearName)="Year 1"))
GROUP BY FYF.ACNT_CODE, FYF.[Team code];

我哪里错了? Access中的Sum部分定义为Total:行

中的表达式

干杯

1 个答案:

答案 0 :(得分:1)

我相信你有一个包围问题 - 这个:

Sum([FYF]![Value])*(1+[IncreaseAssumptions]![Amount]) AS [Year 1 Cost] 

应该是:

Sum([FYF]![Value]*(1+[IncreaseAssumptions]![Amount])) AS [Year 1 Cost]