SQL adding numbers while handling nulls
14:36 25 Oct 2017

I have this statement here:

SELECT sum(table1.foo + table1.bar) AS Sum 
FROM table1
GROUP BY Fname;

When I try to add the numbers from foo and bar if one value from foo or bar is null it throws the numbers and gives me a different count sum

foo | bar
  6    4
  5    null
  9    1 
  2    1
  3    null

I want it to add all the numbers giving me a total of 31

but in this case it gives me a total of 23

sql