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!

Problem with Sum and Decimals

430762Feb 29 2008 — edited Mar 1 2008
Hi,

Can any one please explain me what is happening here?

declare
l_pct_total number:
begin

select nvl(sum(pct_total),0)
into l_pct_total
from my_table
where id = '1234';

if l_pct_total <> 100
then
dbms_output.put_line('l_pct_total is not equal to 100');
else
dbms_output.put_line('l_pct_total is -->' || l_pct_total);
end if;
end;

the result i am getting is 'l_pct_total is not equal to 100'
Table data is:

ID pct_total
1234 1.12946407
1243 1.12360039
1234 1.12360039
1234 0.85603784
1234 0.98874069
1234 94.7785566

Now if i do

select floor(nvl(sum(pct_total),0))
--into l_pct_total
from my_table
where id = '1234';

FLOOR((NVL(SUM(PCT_TOTAL
------------------------------
99

I am wondering what is happening here?

Thanks and Regards
Amit
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 29 2008
Added on Feb 29 2008
13 comments
3,820 views