Re: Aggregate Function (AVG) not calculated correctly

Поиск
Список
Период
Сортировка
От Thomas Lockhart
Тема Re: Aggregate Function (AVG) not calculated correctly
Дата
Msg-id 3A2D0E02.477B467C@alumni.caltech.edu
обсуждение исходный текст
Ответ на Aggregate Function (AVG) not calculated correctly  (pgsql-bugs@postgresql.org)
Список pgsql-bugs
pgsql-bugs@postgresql.org wrote:
>
> Gavin Evans (gavin@consultant.com) reports a bug with a severity of 1
> The lower the number the more severe it is.
>
> Short Description
> Aggregate Function (AVG) not calculated correctly
>
> Long Description
> Using the following code:
> SELECT airline_code, AVG(distance) FROM flights GROUP BY airline_code;
>
> The first line of the result set (AI           | -2864) is calculated wrongly.
> I have included all code needed to prove the bug, this is a SERIOUS BUG!

You have not included all information required to understand the
problem. In particular, what is the schema? What version of PostgreSQL
are you using? What kind of machine?

Do you happen to be using int2 for the distance fields? In that case you
are likely (silently) overflowing your calculation.

Please post the schema and the data in such a way that we can read it
in! I'd suggest using pg_dump on the relevant table, but other
techniques can be used.

Regards.

                     - Thomas

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

Предыдущее
От: pgsql-bugs@postgresql.org
Дата:
Сообщение: Aggregate Function (AVG) not calculated correctly
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Aggregate Function (AVG) not calculated correctly