会'尝试使这个快速......下面的查询。
SELECT PriorityDefID, MilestoneDefID, MilestoneName, ContactName,
IIF(PriorityDefID = 1, (SELECT BonusDaysFH FROM milestone_def WHERE (( MilestoneDefID = IIF(MilestoneDefID = 5, 5, IIF(MilestoneDefID = 6, 6, IIF(MilestoneDefID = 7, 7))) )) ),
IIF(PriorityDefID = 2, (SELECT BonusDaysFM FROM milestone_def WHERE (( MilestoneDefID = IIF(MilestoneDefID = 5, 5, IIF(MilestoneDefID = 6, 6, IIF(MilestoneDefID = 7, 7))) )) ),
IIF(PriorityDefID = 3, (SELECT BonusDaysFL FROM milestone_def WHERE (( MilestoneDefID = IIF(MilestoneDefID = 5, 5, IIF(MilestoneDefID = 6, 6, IIF(MilestoneDefID = 7, 7))) )) ) ))) AS BonusDaysAllotted,
StartDate, EndDate
FROM GetPerformance
WHERE (((MilestoneDefID) = 5 Or (MilestoneDefID) = 6 Or (MilestoneDefID) = 7));
我最终试图获取 MilestoneDefID 的值并在子查询中重用它以确定要返回的 BonusDays 列。子查询希望返回三行,其结果是传递每个值 5、6 和 7。对于从 GetPerformance 查询返回的每一行,我希望它从该行获取 MilestoneDefID,然后进入子查询并传递该 MilestoneDefID返回正确数量的 BonusDays。