luke luke - 2 months ago 6
SQL Question

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

Does

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

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.