On 7 May 2002, Marco Kienzle wrote:
> The following problem occur using the sum() function (see the attached
> file for all the details and an example):
> - if you use it on a portion of a table (example: table age) you get a
> result that differ from the one you can get by hand (see the whole table
> temp1 and do the sum by hand)
> - if you use the sum() function on the complete table (i.e. if you
> first create a temporary table and then run the sum() function) then you
> get the right result (see example on temp1).
Well, since you didn't give data on age, I can't tell for certain, but
your temp table is not necessarily the same as the source. With that
group by I believe you're dropping duplicates if there are any. I'd
suggest seeing what (untested sql)
select inst,year,month,lengthcell,sex,age,agenum,weightmeanage,count(*)
from age where weightmeanage>0 and lengthcell=160 group by inst,
year,month,lengthcell,sex,age,agenum,weightmeanage having count(*)>1;
gives you.