luke luke - 1 year ago 54
SQL Question

Does COUNT(1) - COUNT(column_name) only return the count of null values?


COUNT(1) - COUNT(column_name) as total_nulls

only return the count of null values from a given column?

I feel confident it does but would like to know for certain. Thanks

Answer Source

Yes it does. A more logical and easy to read version would be:

select count(*) from myTable where myColumn is null;

PS: This version would also benefit from existing index.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download