我正在尝试针对访问数据库运行下面的查询,我收到错误没有给定参数的值?
SELECT ID, DateColumn, Less90, Between90180, Between180365, GreaterThan365, SUM(Less90) + SUM(Between90180) + SUM(Between180365) + SUM(GreaterThan365)
AS Total, SUM(Between180365) / Total AS Expr1,
(SELECT SUM(Between180365) / (SUM(Less90) + SUM(Between90180) + SUM(Between180365) + SUM(GreaterThan365))
FROM tblHandpieceFaliuresAge T2
WHERE T2.ID <= tblHandpieceFaliuresAge.ID) AS RunningSum
FROM tblHandpieceFaliuresAge
GROUP BY ID, DateColumn, Less90, Between90180, Between180365, GreaterThan365
答案 0 :(得分:6)
您错误地键入了其中一列,而Access认为您正在尝试传递参数。
再次查看您的字段名称并确保它们都已正确输入。
我认为问题可能是这样的:
SUM(Less90) + SUM(Between90180) + SUM(Between180365) + SUM(GreaterThan365)
AS Total
然后您稍后将其称为Total
:
SUM(Between180365) / Total
Access无法获取别名并在查询中重复使用,您需要:
SUM(Between180365) /
(SUM(Less90) + SUM(Between90180) + SUM(Between180365) + SUM(GreaterThan365))
同时确保你处理分母,这样就不会除以零。
答案 1 :(得分:3)
通常的原因是你拼错了其中一个字段名称,因此,Access认为它是一个参数(未指定)。
有两种方法可以解决这个问题: