I've been asked about counting NULL values several times so I'm going to blog about it in hopes others will be helped by this explanation of NULL values in SQL and how to COUNT them when necessary. Note, my examples make use of a table found in the System Center Configuration Manager database.
I totally NULL what you are talking about now. Thanks for teaching us Admins some SQL skills.
It is much better to use Oracle SQL Singel-row General function NVL, who convert null to actual value.
SELECT COUNT(NVL( , 0))
Something with comments filter...
SELECT COUNT( NVL( column, 0 ) )
WHERE column IS NULL;
Very nice job. This gave me the framework I needed to count Boolean valued columns.
@Newbie, the "NVL" function is essentially the "ISNULL" function in SQL Server (if I'm not mistaken). That function replaces a NULL value with whatever value you provide. I don't see why you'd use it from your examples though since doing "COUNT( NVL( column,
0) )" would be the same thing as doing "COUNT( 0 )" or as I used in my examples "COUNT(1)".