Re: Anomaly with SUM().

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Anomaly with SUM().
Дата
Msg-id 29414.1060372255@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Anomaly with SUM().  (Anthony Best <abest@digitalflex.net>)
Ответы Re: Anomaly with SUM().  (Anthony Best <abest@digitalflex.net>)
Список pgsql-general
Anthony Best <abest@digitalflex.net> writes:
> 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)

That's not an overflow, it's merely roundoff error.  If this surprises
you, possibly you should be using type NUMERIC instead of float.

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Anomaly with SUM().
Следующее
От: Anthony Best
Дата:
Сообщение: Re: Anomaly with SUM().