Re: strange sum behaviour
| От | Karen Hill |
|---|---|
| Тема | Re: strange sum behaviour |
| Дата | |
| Msg-id | 1156872665.455452.289830@m73g2000cwd.googlegroups.com обсуждение исходный текст |
| Ответ на | strange sum behaviour ("Andrew Baerg" <andrew.baerg@gmail.com>) |
| Список | pgsql-general |
"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_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. > You are using the wrong datatype if you are working with currency. Use Numeric or Decimal instead. The "money" type is depreciated. http://www.postgresql.org/docs/8.1/interactive/datatype-money.html
В списке pgsql-general по дате отправления: