Subject RE: [ib-support] Re: integer division
Author Thomas Steinmaurer
select 2.250 / 2 from rdb$database

or

select 2.25 / 2.0 from rdb$database

Be aware that you do not need a valid select statement
if you do a division in PSQL.

For example:

BEGIN
...
C = A / B;
...
END


HTH,
Thomas.

> And if I want an exact division?
>
> 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
>
>
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>