Re: [GENERAL] strange sum behaviour

2006-08-29 Thread Ron Johnson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Alvaro Herrera wrote: > Ron Johnson wrote: >> -BEGIN PGP SIGNED MESSAGE- >> Hash: SHA1 >> >> Seneca Cunningham wrote: >>> On 29-Aug-2006, at 13:13 :48, Andrew Baerg wrote: >> [snip] >>> Take a look at

Re: [GENERAL] strange sum behaviour

2006-08-29 Thread Alvaro Herrera
Ron Johnson wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Seneca Cunningham wrote: > > On 29-Aug-2006, at 13:13 :48, Andrew Baerg wrote: > [snip] > > Take a look at for > > some information about why you should be using numeric for

Re: [GENERAL] strange sum behaviour

2006-08-29 Thread Joshua D. Drake
Ron Johnson wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Seneca Cunningham wrote: On 29-Aug-2006, at 13:13 :48, Andrew Baerg wrote: [snip] Take a look at for some information about why you should be using numeric for your amount colum

Re: [GENERAL] strange sum behaviour

2006-08-29 Thread Ron Johnson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Seneca Cunningham wrote: > On 29-Aug-2006, at 13:13 :48, Andrew Baerg wrote: [snip] > Take a look at for > some information about why you should be using numeric for your amount > column. So how does

Re: [GENERAL] strange sum behaviour

2006-08-29 Thread Chris Mair
> corp=# select amount from acc_trans where trans_id=19721 and chart_id=10019; > amount > - > 4.88 >117.1 > -121.98 > (3 rows) > > corp=# select sum(amount) from acc_trans where trans_id=19721 and > chart_id=10019; > sum > -- > -1.4210854715202e-14

Re: [GENERAL] strange sum behaviour

2006-08-29 Thread John D. Burger
Andrew Baerg wrote: corp=# select amount from acc_trans where trans_id=19721 and chart_id=10019; amount - 4.88 117.1 -121.98 (3 rows) corp=# select sum(amount) from acc_trans where trans_id=19721 and chart_id=10019; sum -- -1.4210854715202e-14 (1 row)

Re: [GENERAL] strange sum behaviour

2006-08-29 Thread Andrew Baerg
Thanks for so many prompt responses. I have researched the differences between floating point and arbitrary precision numbers in the pgsql docs and understand now what is happening. Thanks again to the many great members of the pgsql community. Andrew On 8/29/06, Andrew Baerg <[EMAIL PROTECTED]

Re: [GENERAL] strange sum behaviour

2006-08-29 Thread Seneca Cunningham
On 29-Aug-2006, at 13:13 :48, Andrew Baerg wrote: Hi, I am getting strange results from the sum function as follows: corp=# select amount from acc_trans where trans_id=19721 and chart_id=10019; amount - 4.88 117.1 -121.98 (3 rows) corp=# select sum(amount) from acc_trans where

Re: [GENERAL] strange sum behaviour

2006-08-29 Thread Peter Eisentraut
> corp=# select sum(amount) from acc_trans where trans_id=19721 and > chart_id=10019; > sum > -- > -1.4210854715202e-14 [expected to be 0] Floating-point numbers are typically inaccurate like that, and if you rely in equality comparisons, you're doing something wron

Re: [GENERAL] strange sum behaviour

2006-08-29 Thread codeWarrior
As an alternative -- you could do an inline type cast SELECT SUM(amount)::numeric(10, 2) FROM acc_trans WHERE trans_id=19721 AND chart_id=10019; "Karen Hill" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > "Andrew Baerg" wrote: >> Hi, >> >> I am getting strange results

Re: [GENERAL] strange sum behaviour

2006-08-29 Thread Karen Hill
"Andrew Baerg" wrote: > Hi, > > I am getting strange results from the sum function as follows: > > corp=# select amount from acc_trans where trans_id=19721 and chart_id=10019; > amount > - > 4.88 >117.1 > -121.98 > (3 rows) > > corp=# select sum(amount) from acc_trans where trans

[GENERAL] strange sum behaviour

2006-08-29 Thread Andrew Baerg
Hi, I am getting strange results from the sum function as follows: corp=# select amount from acc_trans where trans_id=19721 and chart_id=10019; amount - 4.88 117.1 -121.98 (3 rows) corp=# select sum(amount) from acc_trans where trans_id=19721 and chart_id=10019; sum ---