我不断收到有关此特定语句的语法错误。
SELECT tbl1.ProjectID, tbl1.EntryDate AS StartDate, tbl2.EntryDate AS EndDate,
(tbl3.ChecklistDayMax - tbl3.ChecklistDayMin + 1) AS DaysAllotted,
(SELECT ProjectPriority FROM project_master WHERE ProjectID = tbl1.ProjectID) AS Priority,
tbl3.MilestoneName,
IIF(Priority = 1, tbl3.BonusDaysFH,
IIF(Priority = 2, tbl3.BonusDaysFM,
IIF(Priority = 3, tbl3.BonusDaysFL))) AS BonusDaysAllotted
FROM (((checklist_entries AS tbl1
INNER JOIN checklist_entries AS tbl2 ON tbl1.ProjectID = tbl2.ProjectID)
INNER JOIN milestone_def AS tbl3 ON [@milestoneID] = milestone_def.MilestoneDefID)
INNER JOIN project_active_status AS tbl4 ON tbl1.ProjectID = project_active_status.ProjectID)
WHERE tbl1.ChecklistDay = tbl3.ChecklistDayMin
AND tbl2.ChecklistDay = tbl3.ChecklistDayMax
AND tbl4.ProjectIsOpen = FALSE;
该错误显示连接操作中的语法错误,然后在第二次 INNER JOIN 之后突出显示里程碑定义。有趣的是,如果我切换这条线......
INNER JOIN milestone_def AS tbl3 ON [@milestoneID] = milestone_def.MilestoneDefID)
用这条线...
INNER JOIN milestone_def AS tbl3 ON [@milestoneID] = tbl3.MilestoneDefID)
我收到错误Join Expression Not Supported然后它突出显示...
[@milestoneID] = tbl3.MilestoneDefID)
但正如你所看到的,在第一次加入...
INNER JOIN checklist_entries AS tbl2 ON tbl1.ProjectID = tbl2.ProjectID
我将其命名为 tbl2,然后使用 tbl2.ProjectID 并且表达式工作得很好。最终,我需要让它发挥作用,不管我如何命名这些东西。
[@milestoneID] 是传递给查询的参数以匹配milestone_def.MilestoneDefID