Re: Aggregate Function (AVG) not calculated correctly

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: gavin(at)consultant(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Aggregate Function (AVG) not calculated correctly
Date: 2000-12-05 15:47:14
Message-ID: 3A2D0E02.477B467C@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

pgsql-bugs(at)postgresql(dot)org wrote:
>
> Gavin Evans (gavin(at)consultant(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tim Dunnington 2000-12-05 16:31:51 plpgsql function error after alter table add
Previous Message Tom Lane 2000-12-05 15:31:18 Re: Aggregate Function (AVG) not calculated correctly