我曾经有一个查询做了很多事情,其中一个是告诉我每个员工的加薪。到期了吗?它已经过期了吗?是不是太早了?
查询一直要求我输入参数,在询问了这个问题后removing "enter parameter value" in query MS access我将一个查询打破成一堆,每个查询都建立在另一个查询之上,直到最后一个具有if条件。 一切都按照我想要的方式工作,除了if条件(之前工作正常!!!)
这是我的条件
Eligibility: IIf([MonthsSinceLastIncrease] < 24, IIf([MonthsSinceLastIncrease] >= 18
AND [LastOfRatings] <= 2, "OVERDUE", IIf([MonthsSinceLastIncrease] >= 15
AND [LastOfRatings] = 1, "OVERDUE", IIf([MonthsSinceLastIncrease] >= 9
AND [MonthsSinceLastIncrease] < 15
AND [LastOfRatings] = 1, "Eligible", IIf([MonthsSinceLastIncrease] >= 12
AND [MonthsSinceLastIncrease] < 18
AND [LastOfRatings] = 2, "Eligible", "ok")))), "OVERDUE")
加薪规则如下:
现在发生的事情是,对于一些员工来说,我只得到一条记录并且这是正确的,但对于一些员工,我得到两条记录,其中一条是正确的,另一条则不是。现在,而不是48条记录(当条件正常时,我曾经得到的记录),我得到58条记录。
这是整个查询的代码
SELECT IIf([MonthsSinceLastIncrease] < 24, IIf([MonthsSinceLastIncrease] >= 18
AND [LastOfRatings] <= 2, "OVERDUE", IIf([MonthsSinceLastIncrease] >= 15
AND [LastOfRatings] = 1, "OVERDUE", IIf([MonthsSinceLastIncrease] >= 9
AND [MonthsSinceLastIncrease] < 15
AND [LastOfRatings] = 1, "Eligible", IIf([MonthsSinceLastIncrease] >= 12
AND [MonthsSinceLastIncrease] < 18
AND [LastOfRatings] = 2, "Eligible", "ok")))), "OVERDUE") AS Eligibility
,MonthsSinceLastUpdateQ.LocalID
,MonthsSinceLastUpdateQ.LastOfRatings
,MonthsSinceLastUpdateQ.MaxOfDateOfUpdate
,MonthsSinceLastUpdateQ.MonthsSinceLastIncrease
FROM MonthsSinceLastUpdateQ
,DateOfUpdateQ
GROUP BY IIf([MonthsSinceLastIncrease] < 24, IIf([MonthsSinceLastIncrease] >= 18
AND [LastOfRatings] <= 2, "OVERDUE", IIf([MonthsSinceLastIncrease] >= 15
AND [LastOfRatings] = 1, "OVERDUE", IIf([MonthsSinceLastIncrease] >= 9
AND [MonthsSinceLastIncrease] < 15
AND [LastOfRatings] = 1, "Eligible", IIf([MonthsSinceLastIncrease] >= 12
AND [MonthsSinceLastIncrease] < 18
AND [LastOfRatings] = 2, "Eligible", "ok")))), "OVERDUE")
,MonthsSinceLastUpdateQ.LocalID
,MonthsSinceLastUpdateQ.LastOfRatings
,MonthsSinceLastUpdateQ.MaxOfDateOfUpdate
,MonthsSinceLastUpdateQ.MonthsSinceLastIncrease;
非常感谢您的帮助,请注意我几乎不知道编码,只是在我去学习MS Access时,谢谢!
答案 0 :(得分:0)
您的查询中的表未链接。通过拖放链接查询设计器中的相关列,如关系创建