I sum up the rows of two columns in two tables i.e. something like this:
SUM( tableA.age ) + sum( tableB.age) as 'Total Ages'
But in some cases the result of table A is null while result of table B is not. In this case I get as a total result null although it is something like "NULL + 45" which is not null actually. Therefore I thought it would be a good idea to use the if clause of the sql syntax. But it does not work I get an error when trying to do the following:
IF SUM( tableA.age ) IS NULL THEN 0 ELSE SUM( tableA.age ) END IF + IF SUM( tableB.age ) IS NULL THEN 0 ELSE SUM( tableB.age ) END IF
How would I do that in a proper way?