Re: bug on aggregate function AVG()

From: "Jose' Soares" <jose(at)sferacarta(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: bug on aggregate function AVG()
Date: 1998-11-03 08:21:05
Message-ID: 363EBCF1.77FBD969@sferacarta.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jose' Soares wrote:
>
> prova=> select * from a;
> int_2| int_4| int_8
> -----+----------+-------------------
> 32767|2147483647|9223372036620802086
> 32767|2147483647|9223372036620802086
> (2 rows)
>
> prova=> select avg(int_2), avg(int_4), avg(int_8) from a;
> avg|avg| avg
> ---+---+----------
> -1| -1|-233973722
> (1 row)
>
> Jose'

The same on SUM():

prova=> select sum(int_2), sum(int_4), sum(int_8) from a;
sum|sum| sum
---+---+----------
-2| -2|-467947444
(1 row)

but it works as follow:

prova=> select avg(int_2*1.0), avg(int_4*1.0), avg(int_8*1.0) from a;
avg| avg|avg
-----+----------+-------------------
32767|2147483647|9.2233720366208e+18
(1 row)

prova=> select sum(int_2*1.0), sum(int_4*1.0), sum(int_8*1.0) from a;
sum| sum|sum
-----+----------+--------------------
65534|4294967294|1.84467440732416e+19
(1 row)

Jose'

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Constantin Teodorescu 1998-11-03 09:12:48 PgAccess latest version
Previous Message Jose' Soares 1998-11-03 08:16:27 bug on aggregate function AVG()