简体   繁体   English

如果找不到匹配项,如何在列中显示0?

[英]How to show 0 in column if no match is found?

I'm doing a left join on two tables. 我正在对两个表进行左联接。 Table one shows potential users while the other table shows actual users. 表一显示了潜在用户,而另一表显示了实际用户。 Potential user is someone in a location who could potentially use our application. 潜在用户是指可能会使用我们的应用程序的人。 Actual user is someone in a location who has in fact used our application. 实际用户是实际使用过我们应用程序的人。

So I want three columns reported. 所以我想报告三栏。 Location, Actual Users, Potential Users 位置,实际用户,潜在用户

Now, I want to always show the potential user number -- even when actual users is 0, too. 现在,我想始终显示潜在的用户数-即使实际用户也为0。 This is no problem. 没问题 Potential users will show 0 in the field (its 0 in the source table). 潜在用户将在该字段中显示0(在源表中显示0)。

But if actual user is 0, its displaying blank. 但是,如果实际用户为0,则显示为空白。 How can I display this as 0 in Access? 如何在Access中将其显示为0?

Potential Users Table 

Location   | Potential    
-----------+---------  
New Jersey | 4  
Ohio       | 2

Actual Users Table  

Location   | Actual  
-----------+---------  
Ohio       | 1

Right now, if I do a left join. 现在,如果我进行左联接。 It'll show: 它会显示:

Location   | Potential | Actual 
-----------+-----------+------- 
New Jersey | 4         |   
Ohio       | 2         | 1

What I'd like to do is for New Jersey to show a 0 in the Actual column. 我要为新泽西州在“实际”列中显示0。 Any ideas? 有任何想法吗?

Try: 尝试:

Nz(Actual, 0) AS Actual

Other option removed 其他选项已删除

尝试如下使用

 COALESCE(Actual, 0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM