Subject Re: [firebird-support] Problem with a division
Author Martijn Tonies
Hello Werner,

>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,

/100 results in an integer.

Try:

(oldprice/100.0000)

(or 100.00)

> 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

With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!

Database questions? Check the forum:
http://www.databasedevelopmentforum.com