So I came across something the other day at work, trying to count how many null values after running an import.
So, I did:
select COUNT(columnname) from table
WHERE ColumnName is null
Which didn't count the nulls...
Then I did,
select COUNT(*) from table
WHERE ColumnName is null
Which gave me the count.
So, something that bugged me is why exactly this doesn't count the null values.
I have looked at this question (along with a good search around Google...):
In SQL, what's the difference between count(column) and count(*)?,
and whilst it tells me that COUNT(columnname)
doesn't count nulls, I would like to know exactly why nulls aren't counted using this method?
Many Thanks, James.