Andrew Gould <andrewgould@yahoo.com> writes:
> I need an aggregate function that calculates geometric
> mean, and can be used in SQL statements the same as
> any other aggregate function such as count(), sum()
> and avg(). Rather than have a custom function, I'd
> like to see it added as a standard PostgreSQL feature.
One request does not strike me as sufficient reason to make it a
standard feature. Extensibility is what Postgres is all about
--- so go ahead and write your own.
AFAICS this should take about ten minutes to prototype (two simple
plpgsql or pltcl functions and a user-defined aggregate). If you intend
to process very large volumes of data, it might be worth rewriting the
transition function in C for speed. (You could steal the existing
transition function for avg() as a model.)
regards, tom lane