Skip site navigation (1) Skip section navigation (2)

Re: problem with the sum function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marco Kienzle <m(dot)kienzle(at)marlab(dot)ac(dot)uk>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: problem with the sum function
Date: 2002-05-07 14:37:56
Message-ID: 23443.1020782276@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Marco Kienzle <m(dot)kienzle(at)marlab(dot)ac(dot)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

In response to

pgsql-bugs by date

Next:From: pgsql-bugsDate: 2002-05-07 14:51:12
Subject: Bug #659: lower()/upper() bug on ->multibyte<- DB
Previous:From: Dmitry TkachDate: 2002-05-07 14:23:08
Subject: Re: problem with the sum function

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group