I'm doing a query on mysql and so far I have this
SUM(IF(val1 IS NULL, val2, val1 )) AS total
But is it possible to do something like that?
SUM(IF(val1 IS NULL, if(val2 is null, 0, val2) val1 )) AS total
Where I say that if val1
is null put val2
but before putting val2
ask again if this null to put 0