sql server count 0 if null code example
Example: sql count null as 0
SELECT sum(CASE WHEN column_A IS NULL THEN 1 ELSE 0 END) A,
sum(CASE WHEN column_B IS NULL THEN 1 ELSE 0 END) B
FROM my_table;
SELECT sum(CASE WHEN column_A IS NULL THEN 1 ELSE 0 END) A,
sum(CASE WHEN column_B IS NULL THEN 1 ELSE 0 END) B
FROM my_table;