我已经尝试了在这种情况下返回值的所有公式,但不断收到错误消息,告诉我我的参数数量错误。这是我的查询:
SELECT [ER Root].[Network Indicator],
[ER Root].[Prov Indicator],
[ER Root].[Pos Indicator],
[ER].[ER Visit]
FROM [ER Root] LEFT JOIN ER ON ([ER Root].[Network Indicator] = ER.[Network Flag]) AND ([ER Root].[Pos Indicator] = ER.[POS Indicator]) AND ([ER Root].[Prov Indicator] = ER.[Category Indicator]);
我试过了:
SELECT [ER Root].[Network Indicator],
[ER Root].[Prov Indicator],
[ER Root].[Pos Indicator],
ISNULL([ER].[ER Visit],0) AS "ER Visit"
FROM [ER Root] LEFT JOIN ER ON ([ER Root].[Network Indicator] = ER.[Network Flag]) AND ([ER Root].[Pos Indicator] = ER.[POS Indicator]) AND ([ER Root].[Prov Indicator] = ER.[Category Indicator
我究竟做错了什么?
最佳答案
Access ' ISNULL
函数只接受一个参数并返回一个 bool 值。
如果您想返回 0
当[ER Visit]
为空,您可以使用 Nz
在从 Access session 中运行的查询中。
SELECT Nz([ER Visit], 0) AS ER_Visit
注意,我使用了
ER_Visit
作为别名,因为如果您尝试将字段名称重新用作别名,数据库引擎可能会提示“循环”引用。如果您从 Access session 外部(如从经典 ASP 或 .Net)运行查询,
Nz
功能将不可用。你可以这样做......SELECT IIf([ER Visit] Is Null, 0, [ER Visit]) AS ER_Visit
关于ms-access - 在 Access 查询中的左外连接上为空记录重新调整值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10178249/