Sql 无法在MS Access查询中显示0或Null
我正在尝试在MS Access中运行sql查询。我正在尝试加入一些表/查询Sql 无法在MS Access查询中显示0或Null,sql,ms-access,Sql,Ms Access,我正在尝试在MS Access中运行sql查询。我正在尝试加入一些表/查询 MonthlyTargets\u 0\u SPARTN\u qry从SPARTN\u Livefeed1中选择信息 SPARTN_Livefeed1包含由主管完成的测试 参考测试目录-测试编号和说明列表 REF_TestCategory_tbl-类别列表(每个测试编号所属的存储桶) 查询工作正常,但如果当月未完成任何测试,则需要显示“0”。 参见预期结果第4行,主管在2020年1月1日未进行任何第4类试验-(无记录 在S
SELECT REF_TestCategory_tbl.CategoryID,
MonthlyTargets_0_SPARTN_qry.[Supervisor Id] AS TestOfficerID,
Count(MonthlyTargets_0_SPARTN_qry.[Sheet ID]) AS Actuals,
MonthlyTargets_0_SPARTN_qry.ComplianceMonth
FROM MonthlyTargets_0_SPARTN_qry
INNER JOIN
( REF_TestCategory_tbl
INNER JOIN REF_TestCatalog_tbl ON REF_TestCategory_tbl.CategoryID = REF_TestCatalog_tbl.TestCategory) ON MonthlyTargets_0_SPARTN_qry.[Test Number] = REF_TestCatalog_tbl.TestID
GROUP BY REF_TestCategory_tbl.CategoryID, MonthlyTargets_0_SPARTN_qry.[Supervisor Id], MonthlyTargets_0_SPARTN_qry.ComplianceMonth
ORDER BY REF_TestCategory_tbl.CategoryID;
这有帮助吗:没有,因为根本没有返回null或0。当前查询的实际结果是什么?(或者我错过了吗?)类别ID TestOfficeId实际合规性月1 806855 2 1/1/2020 2 806855 1 1/1/2020 3 806855 3 1/1/2020“我需要显示”0“如果当月未进行任何测试”,但您的预期结果与上月一致?您说“当月”是什么意思?
SPARTN_Livefeed1
Sheet ID Date Test Number Supervisor ID
OB-1234 1/1/2020 101 806855
OB-5678 1/1/2020 101 806855
OB-9877 1/1/2020 112 806855
OB-5644 1/1/2020 123 806855
OB-5644 1/1/2020 123 806855
REF_TestCatalog_tbl
ID TestId TestDesc TestCategory StartDate EdnDate
1 101 Stopping 1 12/1/2019
2 112 Delay 2 12/1/2019
3 123 Documents 3 12/1/2019
4 134 Radio 4 12/1/2019
REF_TestCategory_tbl
ID CategoryID CategoryDesc StartDate EndDate
1 1 Signals 12/1/2019
2 2 Speed 12/1/2019
3 3 Equipment 12/1/2019
4 4 Operation 12/1/2019
Expected Results
CategoryID TestofficerID Actuals ComplianceMonth
1 806855 2 1/1/2020
2 806855 1 1/1/2020
3 806855 3 1/1/2020
4 806855 0 1/1/2020
SELECT REF_TestCategory_tbl.CategoryID,
MonthlyTargets_0_SPARTN_qry.[Supervisor Id] AS TestOfficerID,
Count(MonthlyTargets_0_SPARTN_qry.[Sheet ID]) AS Actuals,
MonthlyTargets_0_SPARTN_qry.ComplianceMonth
FROM MonthlyTargets_0_SPARTN_qry
INNER JOIN
( REF_TestCategory_tbl
INNER JOIN REF_TestCatalog_tbl ON REF_TestCategory_tbl.CategoryID = REF_TestCatalog_tbl.TestCategory) ON MonthlyTargets_0_SPARTN_qry.[Test Number] = REF_TestCatalog_tbl.TestID
GROUP BY REF_TestCategory_tbl.CategoryID, MonthlyTargets_0_SPARTN_qry.[Supervisor Id], MonthlyTargets_0_SPARTN_qry.ComplianceMonth
ORDER BY REF_TestCategory_tbl.CategoryID;