帐户为空字段

时间:2018-12-18 01:52:59

标签: sql ms-access

是否可以通过在Nz,IIf(IsNull())或类似的地方添加一些查询来计算空字段?

SELECT DISTINCTROW
 mytable.[field1],
 mytable.[field2],
 mytable.[field3]

FROM mytable

WHERE (((mytable.[field1]) In (SELECT [field1] FROM [mytable] As Tmp GROUP BY

[field1],
[field2],
[field3]

HAVING Count(*)>1 And

[field1] = [mytable].[field1] And 
[field2] = [mytable].[field2] And 
[field3] = [mytable].[field3]
)));

不返回任何内容,因为 field3 中有空字段

有没有办法放

IIf(IsNull(field3), "emptyfield", field3)

或查询中某处的类似内容,以便将空的field3考虑在内?

1 个答案:

答案 0 :(得分:0)

尝试一个或两个 Nz

Nz([field1], [mytable].[field1]) = [mytable].[field1]
' or:
[field1] = Nz([mytable].[field1], [field1])
' or:
Nz([field1], [mytable].[field1]) = Nz([mytable].[field1], [field1])

' or, if text:
Nz([field1], "") = Nz([mytable].[field1], "")
' or, if numeric:
Nz([field1], 0) = Nz([mytable].[field1], 0)