luke luke - 1 month ago 5x
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


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.