Subject | Re: integer division |
---|---|
Author | ronaldorezende |
Post date | 2003-03-27T19:51:25Z |
And if I want an exact division?
ex: 2.25 / 2 = 1.125
--- In ib-support@yahoogroups.com, "Thomas Steinmaurer" <ts@i...>
wrote:
ex: 2.25 / 2 = 1.125
--- In ib-support@yahoogroups.com, "Thomas Steinmaurer" <ts@i...>
wrote:
> > How can I make an integer division in sql or stored procedure?
>
> Simply by using the division operator '\'?
>
> If you have two integers, then the result will automatically
> be an integer too. For example:
>
> select 5 / 4 from rdb$database
>
> If the numerator or the denominator isn't an integer, and you
> still want an integer as result, then CAST the non integer
> value before doing the division. For example:
>
> select cast(5.00 as integer) / 4 from rdb$database
>
> Or in a dialect 3 database, you may use NUMERIC(18,0) for
> a huge number, because this is internally mapped to an 64
> bit integer.
>
> For example:
>
> select cast(2342352352353255.00 as numeric(18,0)) / 4
> from rdb$database
>
>
> Regards,
> Thomas Steinmaurer
> http://www.iblogmanager.com