strange sum behaviour

From: "Andrew Baerg" <andrew(dot)baerg(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: strange sum behaviour
Date: 2006-08-29 17:13:48
Message-ID: 2b46a06b0608291013v75cc035eoc0ea3ae179581c17@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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
----------------------
-1.4210854715202e-14
(1 row)

amount is defined as double precision. I noticed that if I cast amount
as numeric, the sum comes out 0 as expected.

I am using postgresql 8.0.1

Thanks in advance for any help or suggestions.

Andrew Baerg

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jasbinder Bali 2006-08-29 17:29:28 Re: Shared Objects (Dynamic loading)
Previous Message David Fetter 2006-08-29 16:56:07 Re: Anonymous stored procedures