SUM for columns with null values
The column contains both values and missing values. Will SUM function work for such columns by ignoring those null values?Thanks.
Hi Christine Li!
Thanks for reaching out.
SUM() is supposed to ignore null values. In any case, if you want to be specific, you can instruct the SQL Optimiser to substitute the null values with the value of 0. To do that, you can help yourself with the COALESCE() function and the following model:
SELECT COALESCE(SUM(column_name), 0) ...
Hope this helps.