"Gene Sokolov" <hook(at)aktrad(dot)ru> writes:
> test1=> select count(*), max("ID"), min("ID"), avg("ID") from "ItemsBars";
> count| max| min| avg
> ------+-------+-----+----
> 677719|3075717|61854|-251
> Overflow, perhaps?
sum() and avg() for int fields use int accumulators. You might want
to use avg(float8(field)) to get a less-likely-to-overflow result.
Someday it'd be a good idea to revise the sum() and avg() aggregates
to use float or numeric accumulators in all cases. This'd require
inventing a few more cross-data-type operators...
regards, tom lane