SUM return 0 where no rows found
yoxlerOct 30 2008 — edited Oct 31 2008I have the following SQL:
SELECT
a.extraction_date,
sum(a.balance),
sum(b.ded_balance),
sum(a.balance) + sum(b.ded_balance) amount
FROM a
LEFT OUTER JOIN b ON a.extraction_date = b.extraction_date
GROUP BY
a.extraction_date
However, some dates does not exist in b, which makes b.ded_balance do become blank(or null) and not 0.
This leads to that sum(a.balance) + sum(b.ded_balance) amount does not work since b.ded_balance is blank. So it also becomes blank despite data in a.balance
How do I solve this?