Re: problem with the sum function - Mailing list pgsql-bugs

From Tom Lane
Subject Re: problem with the sum function
Date
Msg-id 23443.1020782276@sss.pgh.pa.us
Whole thread Raw
In response to problem with the sum function  (Marco Kienzle <m.kienzle@marlab.ac.uk>)
List pgsql-bugs
Marco Kienzle <m.kienzle@marlab.ac.uk> writes:
> herring=3D# select sum(agenum) from age where weightmeanage>0 and lengthcel=
> l=3D160;
>  sum=20
> -----
>   77
> (1 row)

>  select INTO TABLE temp1 inst, year, month, lengthcell, sex, age, agenum, w=
> eightmeanage from age where weightmeanage>0 and lengthcell=3D160 group by i=
> nst, year, month, lengthcell, sex,age,agenum, weightmeanage;

> herring=3D# select sum(agenum) from temp1;
>  sum=20
> -----
>   73
> (1 row)

Why would you expect these to give the same result?  The "group by"
effectively eliminates duplicate rows, thus removing some contributions
to the sum.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Dmitry Tkach
Date:
Subject: Re: problem with the sum function
Next
From: pgsql-bugs@postgresql.org
Date:
Subject: Bug #659: lower()/upper() bug on ->multibyte<- DB