我遇到了一个问题,如果你们能帮助我,我将不胜感激。
我们正在使用一个表(MS Access)来存储多个公司的项目计划,如下所示:
ID PROJECT_NAME COMPANY_NAME MILESTONE_NAME MILESTONE_TYPE
我查询的目标是返回“适用”推出的数量。
推出是项目和公司的独特组合。例子:
Project 1 being executed in the Company A
Project 2 being executed in the Company A
Project 1 being executed in the Company B
适用的项目是它的最后一个里程碑具有不同于“DUMMY”的 MILESTONE_TYPE 的任何项目。
适用的推出应如下所示:
ID PROJECT_NAME COMPANY_NAME MILESTONE_NAME MILESTONE_TYPE
1 Project 3 Company D 6.2 Rollout Completed Applicable
为了检索项目的最后一个里程碑,我使用以下 SQL:
SELECT Sheet1.[PROJECT_NAME], MAX(Sheet1.[MILESTONE_NAME])
FROM Sheet1
INNER JOIN Sheet1 AS Sheet1_1 ON (Sheet1.[PROJECT_NAME] = Sheet1_1.[PROJECT_NAME])
AND (Sheet1.[MILESTONE_NAME] = Sheet1_1.[MILESTONE_NAME])
GROUP BY Sheet1.[PROJECT_NAME]
ORDER BY Sheet1.[PROJECT_NAME]
我需要您的支持的查询的预期结果是:
PROJECT_NAME COUNT_OF_APPLICABLE_ROLLOUTS
Project A 5
Project B 6
但是我完全不知道如何开始......有谁知道如何将所有内容放入 SQL 查询中?
提前致谢。