Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SUM return 0 where no rows found

yoxlerOct 30 2008 — edited Oct 31 2008
I 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?
This post has been answered by 26741 on Oct 30 2008
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 28 2008
Added on Oct 30 2008
9 comments
25,898 views