Count Query Not Counting Nulls

D

Dale

Access 2000

The following query does not count nulls, How can I
include the null count also?

SELECT Count(qStatsPtType.TypeOfPatientDesc) AS
CountOfTypeOfPatientDesc, qStatsPtType.TypeOfPatientDesc
FROM qStatsPtType
GROUP BY qStatsPtType.TypeOfPatientDesc
ORDER BY qStatsPtType.TypeOfPatientDesc;

This query returns a count of each Pt Type, If the pt
type is null, then it does not show in the results that X
number of records have a blank Pt Type.

TIA
Dale
 
M

Michel Walsh

Hi,


That is by definition, in SQL. COUNT(*) counts all the records (after
the criteria WHERE is applied, before the HAVING), while COUNT(FieldName)
counts only the number of not null values in the said field. If you want the
null into the count, use COUNT(*).


Hoping it may help,
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