我需要将Table1.Budget
更新为sum(Employee.[Monthly budget])
,只考虑招聘日期在Table1.Date
之后的员工。
我正在尝试使用此查询:
UPDATE Table1 SET Budget = (Sum(Employee.[Monthly budget])) WHERE Table1.Date > Employee.[Date of recruitment];
但我收到此错误:
编辑
我正在使用以下代码:
UPDATE Table1
SET Budget = (SELECT Sum(Employee.[Monthly budget]) FROM Employee WHERE Table1.Date > Employee.[Date of recruitment]);
但是我收到错误消息Operation must use an updatable query
。
答案 0 :(得分:1)
我想您可能想要一个子查询:
UPDATE Table1
SET Budget = (SELECT Sum(Employee.[Monthly budget]) FROM Employee WHERE Table1.Date > Employee.[Date of recruitment]);
答案 1 :(得分:0)
我看不到员工的任何选择
UPDATE Table1
SET Budget =
SELECT Sum(Employee.[Monthly budget])
FROM Employee
WHERE Table1.[Date] > Employee.[Date of recruitment];
答案 2 :(得分:0)
如果遇到“操作必须使用可更新的查询”问题,只需将子查询替换为DSUM()
。
它可能会慢一些,但应该可以完成工作。
UPDATE Table1
SET Budget = DSUM("Monthly Budget", "Employees", "[Date of recruitement] < " & [Date])
(写得很快,但您明白了)
使用Date作为字段名称是一个非常糟糕的主意!!!