Given table:
ID ONE TWO
X1 15 15
X2 10 -
X3 - 20
This query:
SELECT (ONE + TWO) FROM (TABLE)
Just returns the sum of X1‘s values but not the others since at least one column has a null value. How can I still add them even if there is a null? i.e. consider the null as a 0 maybe?
COALESCEwill return the first non-null value found in the parameters from left to right. So, when the first field is null, it will take the 0.That way,
X2will result in10 + 0 = 10