Gonna' try to make this quick... Query below.
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));
I am ultimately trying to get the value of the MilestoneDefID and reuse it in the subquery to determine which BonusDays column to return. The subquery wants to return three rows with the results of passing each value of 5, 6 and 7. For each row returned from the GetPerformance query, I want it to take the MilestoneDefID from that row and then go into the subquery and pass that MilestoneDefID to return the correct number of BonusDays.