【发布时间】:2017-03-22 15:30:18
【问题描述】:
如果这个问题已经存在,我深表歉意 - 我已尝试寻找解决方案,但尚未找到解决方案。
我有一个数据库模板,用于设置单独的数据库来处理不总是采用相同格式或有时具有附加字段的客户端数据。我正在尝试构建一个查询来测试累积表的结果,并确保设置新数据库的分析师没有遗漏任何内容。最终我只需要一种方法来显示累积表中是否有任何字段对于每条记录都是 NULL 并告诉我字段名称。
我尝试使用 SWITCH 和 IIF 设置查询,但涉及的字段太多,所以我总是收到 Expression Too Complex 错误。
这是一个查询示例,尽管我的数据库最终将有 70 个字段需要在设置后测试空值。
SELECT SWITCH(
TBL_Cumulative.[ScreeningDate] IS NULL, "ScreeningDate Missing",
TBL_Cumulative.[ScreeningLocation] IS NULL, "ScreeningLocation Missing",
TBL_Cumulative.[Source] IS NULL, "Source Missing",
TBL_Cumulative.[FirstName] IS NULL, "FirstName Missing",
TBL_Cumulative.[LastName] IS NULL, "LastName Missing",
TBL_Cumulative.[DOB] IS NULL, "DOB Missing",
TBL_Cumulative.[Female] IS NULL, "Female Missing",
TBL_Cumulative.[Male] IS NULL, "Male Missing",
TBL_Cumulative.[Height_FT] IS NULL, "Height_FT Missing",
TBL_Cumulative.[Height_IN] IS NULL, "Height_IN Missing",
TBL_Cumulative.[Weight] IS NULL, "Weight Missing",
TBL_Cumulative.[Fasting_Y] IS NULL, "Fasting_Y Missing",
TBL_Cumulative.[Fasting_N] IS NULL, "Fasting_N Missing",
TBL_Cumulative.[Pregnant_Y] IS NULL, "Pregnant_Y Missing",
TBL_Cumulative.[Pregnant_N] IS NULL, "Pregnant_N Missing",
TBL_Cumulative.[Tobacco_Y] IS NULL, "Tobacco_Y Missing",
TBL_Cumulative.[Tobacco_N] IS NULL, "Tobacco_N Missing",
TBL_Cumulative.[hbA1c] IS NULL, "hbA1c Missing",
TBL_Cumulative.[Cotinine] IS NULL, "Cotinine Missing",
TBL_Cumulative.[TSH] IS NULL, "TSH Missing",
TBL_Cumulative.[PSA] IS NULL, "PSA Missing") AS Error FROM TBL_Cumulative
【问题讨论】: