Count Only Non-Zero Values

G

Guest

Is there a way to count only non-zero values in a query, and ignore zero
values? The numeric field is substituted with 0 (zero) if it's null. Any
pointers are greatly appreciated. Thanks.
 
K

Ken Snell \(MVP\)

Substituted by what means? Nz function? Or by Format property? Show us an
example of the query that you're trying to use.

In general, one can count such things by using a Sum aggregate function in
this way:

SELECT Field1, Sum(IIf(Field2 Is Null, 0, 1)) AS NonNullCountField2
FROM TableName
GROUP BY Field1;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top