avg() bug?

From: Patrik Kudo <kudo(at)partitur(dot)se>
To: <pgsql-general(at)postgresql(dot)org>
Subject: avg() bug?
Date: 2001-03-05 16:55:41
Message-ID: Pine.BSF.4.31.0103051750060.976-100000@tb303.partitur.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi!

I'm not sure if this is a bug, but it's sure unpleasant (for me).

(pseudocode)
create table t (a int2);

insert into t values (random number); <-- performed many, many times

now the following will return very unpredictable values:

select avg(a) from t;

while the following behaves as I would expect:

select avg(a::int4) from t;

I suppose avg() does a sum()/count() where sum returns a int2,
which will be too small to contain the sum if the table contains
many values?

Is this something I must know as a user, or is it a bug?

Regards,
Patrik Kudo

--
ech`echo xiun|tr nu oc|sed 'sx\([sx]\)\([xoi]\)xo un\2\1 is xg'`ol
Känns det oklart? Fråga på!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2001-03-05 17:16:41 Re: name vs text vs varchar
Previous Message mike 2001-03-05 16:53:18 name vs text vs varchar