Count Null fields

G

Guest

I have a table called dbo_Feature and column called FeatureDateClosed.
I want to get a count of any records where the FeatureDateClosed column is
null. I tried a simple count(FeatureDateClosed) query, with no luck. See
below:

SELECT Count(dbo_Feature.FeatureDateClosed) AS Expr1
FROM dbo_Feature
WHERE ((dbo_Feature.FeatureDateClosed) Is Null);

This gives me zero. It should be about 1100. I vaguely recall that count
isn't for null values, but don't remember the work around. Any help?
 
G

Guest

Do the count on a different field, that has a value

SELECT Count(dbo_Feature.[Different field name that is not Null]) AS Expr1
FROM dbo_Feature
WHERE ((dbo_Feature.FeatureDateClosed) Is Null);
 
G

Graham Mandeno

Hi Nathan

By design, records containing Null in the field that is being counted are
not included in the Count, so this query will always return zero.

To count all records, whether or not they contain nulls, use an asterisk:

SELECT Count(*) AS NullDate FROM dbo_Feature
WHERE dbo_Feature.FeatureDateClosed Is Null;
 

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