Totals Won't Count Nulls

J

jgraves

My Access Table has a columns containing various values, including null. See
below.

Error Code
------------
A
A
B
C
(Null)
C
D
V
(Null)

I am trying to produce query results where each code is displayed with the
number of times it appears by using Totals. Using design view, I drag the
column name down twice, click Totals, then change one to "Group" and one to
"Count". Fine except that my query results show zero for "Null" no matter how
many nulls appear. Why won't it show 2 nulls, for example if the above data
was being used?

Here is what results:
Error Code CountofError Code
------------ ----------------------
(null) 0
A 2
B 1
C 2
D 1
V 1

Thanks for any help whatsoever.

Jen Graves
 
V

vanderghast

COUNT(*) counts the nulls, COUNT(fieldOrExpression) does not count the
nulls.


SELECT errorCode, COUNT(*)
FROM somewhere
GROUP BY errorCode


instead of

SELECT errorCode, COUNT(errorCode)
FROM somewhere
GROUP BY errorCode



Vanderghast, Access MVP
 

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

Top