Subject | Problem with a division |
---|---|
Author | Werner F. Bruhin |
Post date | 2009-09-16T08:34:31Z |
I can't figure out why I get a different result on division with FB then
e.g. doing it in Python.
My sql:
select newprice, oldprice, (newprice-oldprice)/(oldprice/100) as perc,
extract(year from created) as statsyear, extract(month from created) as
statsmonth from pricechange;
Result:
NEWPRICE OLDPRICE PERC STATSYEAR STATSMONTH
25 21,3 17,619 2009 9
In Python I get:
What am I missing? I am pretty sure I am doing a stupid mistake:)
Werner
P.S. both newprice and oldprice are numeric(18, 2) columns
e.g. doing it in Python.
My sql:
select newprice, oldprice, (newprice-oldprice)/(oldprice/100) as perc,
extract(year from created) as statsyear, extract(month from created) as
statsmonth from pricechange;
Result:
NEWPRICE OLDPRICE PERC STATSYEAR STATSMONTH
25 21,3 17,619 2009 9
In Python I get:
>>> (25.00-21.30)/(21.30/100)17.37089201877934
What am I missing? I am pretty sure I am doing a stupid mistake:)
Werner
P.S. both newprice and oldprice are numeric(18, 2) columns