Peter Eisentraut wrote:
>
> Patrik Hall writes:
>
> > I am in need of median, quartile and percentile functions in postgres.
> >
> > Has anybody implemented any of them allready?
>
> Haven't heard, but if you can come up with a way to calculate them with a
> single pass over the data rows (keeping several state variables, if
> necessary) then you're half way there to implementing your own aggregate
> function. See the Programmer's Guide on how that might be done.
>
> Incidentally I couldn't think of a way to do just that. In that case it
> will be *hard*.
Forgive me if I already said this...May I suggest a lovely little perl
package called Statistics::Descriptive which I use for this sort of
thing? I know it's not exactly what your were looking for, but it's a
possible consideration if you happen to be accessing pgsql via
perl/DBI.
Cheers,
Ed Loehr