Re: Anomaly with SUM().

From: Dennis Gearon <gearond(at)cvc(dot)net>
To: Anthony Best <abest(at)digitalflex(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Anomaly with SUM().
Date: 2003-08-08 19:28:56
Message-ID: 3F33F9F8.6050904@cvc.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

are these float values?

Anthony Best wrote:

> I've noticed that the SUM() seems to overflow under some situations.
>
> The only difference is the order that the data is retrived from the
> database.
>
>
>
> accounting=# select sum(amount) from transactions, chart WHERE
> account=chart.id;
> sum
> ---------------------
> 5.6843418860808e-14
> (1 row)
>
> accounting=# select sum(amount) from transactions, chart WHERE
> account=chart.id AND amount=amount;
> sum
> -----
> 0
> (1 row)
>
>
>
>
> More Info:
> accounting=# select amount from transactions, chart WHERE
> account=chart.id;
> amount
> --------
> -75
> 21.13
> -83
> 2.13
> -83
> 21
> 50
> 50
> 2.26
> -166
> 99
> 2.21
> -83
> -100
> 39
> 25
> -70
> -0.02
> 45
> -0.05
> -0.05
> -0.04
> -0.04
> 70
> 75
> 83
> 83
> 166
> 83
> 100
> 0.02
> 0.05
> 0.05
> 0.04
> 0.04
> -21
> -45
> -21.13
> -2.13
> -2.26
> -2.21
> -50
> -50
> -99
> -39
> -25
> (46 rows)
>
> accounting=# select amount from transactions, chart WHERE
> account=chart.id AND amount=amount;
> amount
> --------
> -70
> 70
> -75
> 75
> -0.02
> 0.02
> -45
> 45
> -21.13
> 21.13
> -0.05
> 0.05
> -83
> 83
> -0.05
> 0.05
> -2.13
> 2.13
> -83
> 83
> -21
> 21
> -50
> 50
> -0.04
> 0.04
> -50
> 50
> -2.26
> 2.26
> -166
> 166
> -99
> 99
> -0.04
> 0.04
> -2.21
> 2.21
> -83
> 83
> -100
> 100
> -39
> 39
> -25
> 25
> (46 rows)
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-08-08 19:50:55 Re: Anomaly with SUM().
Previous Message Stephan Szabo 2003-08-08 19:21:01 Re: Anomaly with SUM().