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 with condition.

mlov83Jul 12 2009 — edited Jul 12 2009
hello guys I have a simple query but it just dosent seem to work. I have a column that I like to only add when another column is between a range, but i keeping getting "0" even though some part of the range does contain values. can someone please point out the obvious.

Thanks in advance
select nvl(sum(fgbopal_14_ytd_actv),0)  from fgbopal
where fgbopal_fund_code = '400002' 
and nvl((fgbopal_acct_code),0) between '7000' and '7019'  
and nvl((fgbopal_acct_code),0) between '7046' and '7177'
FYI If part of the range has a value but the other part does not, I still get a "0".
Help!
This post has been answered by Frank Kulash on Jul 12 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 9 2009
Added on Jul 12 2009
4 comments
509 views