Nz() 在 MS Access 中不起作用
我有一个交叉表查询,它将 Patient_ID 计算为值。
Total = Nz(Count(Research.Patient_ID))+0
我也尝试过:
Total = Nz(Count(Research.Patient_ID)
和...
Total = Nz(Count(Research.Patient_ID, 0)
等。 Nz() 仅在至少一个值不为空时才有效。然而,如果它们全部为空,我就什么也看不到,而不是全是 0。
这是有问题的,因为我将这些查询用作子查询。主查询从该查询(以及其他类似的查询)中获取值并将它们加在一起。不幸的是,如果子查询之一完全为空,那么无论是否应该为空,总和实际上都会为空。
例如:
subquery1: Nz(Count(Research.Patient_ID))+0
subquery2: Nz(Count(Research.All_ID))+0
mainquery: subquery1 + subquery2
if subquery1 = 4, and subquery2 = Null...
mainquery = subquery1 + subquery2
mainquery = Null
当真的...
mainquery = 4
请帮忙。
I have a cross tab query that is counting Patient_ID's as the value.
Total = Nz(Count(Research.Patient_ID))+0
I have also tried:
Total = Nz(Count(Research.Patient_ID)
and....
Total = Nz(Count(Research.Patient_ID, 0)
etc. Nz() only works if at least one value is not null. However, if all of them are null, instead of seeing all 0's, I see nothing.
This is problematic because I am using these queries as subqueries. The main query takes the values from this one (and others like it) and adds them together. Unfortunately, if one of the subqueries is entirely null, then the sum actually turns up null, regardless of whether or not should be.
For example:
subquery1: Nz(Count(Research.Patient_ID))+0
subquery2: Nz(Count(Research.All_ID))+0
mainquery: subquery1 + subquery2
if subquery1 = 4, and subquery2 = Null...
mainquery = subquery1 + subquery2
mainquery = Null
when really...
mainquery = 4
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在此查询中,主查询生成两个子查询中确定的计数之和。这就是你所追求的吗?
In this query, the main query produces the sum of counts determined in two subqueries. Is this what you're after?
nz(null, null)+0
将始终为null
,因为null + everything
为null
。如果
nz()
可以返回null
,则只需应用另一个nz()
来处理它;nz(null, null)+0
will always benull
asnull + anything
isnull
.If
nz()
can returnnull
, just apply anothernz()
to handle it;您可能应该更详细地发布主查询的确切部分,其中两个计数相加。
到目前为止,我只能猜测您需要将
NZ()
添加到主查询表达式中,例如(使用伪代码)You should probably be more elaborate and post the exact part of your main query where the two counts are being added up.
So far I can only guess that you need to add
NZ()
to the main query expression, something like (using your pseudo-code)