Aggregate working on ordered data - Mailing list pgsql-general

From Christoph Dalitz
Subject Aggregate working on ordered data
Date
Msg-id 20021219104031.7c4ab598.christoph.dalitz@hs-niederrhein.de
Whole thread Raw
Responses Re: Aggregate working on ordered data
List pgsql-general
Hello,

while trying to implement an aggregate function "median", I am
facing two problems:

 a) In order to compute the median, the input values of the aggregate
    function need to come in ordered.

 b) Computation of the statistical median requires *two* runs of
    the aggregation: a simple count and a run until count/2 on the
    ordered data.

Is it at all possible to implemnt such an aggregate function in PostgreSQL?
If yes, all suggestions are appreciated.

Thanks,

Christoph Dalitz

pgsql-general by date:

Previous
From: Conxita Marín
Date:
Subject: Re: SELECT EXTRACT doesn't work with variables?
Next
From: Lee Kindness
Date:
Subject: trouble caused by change in 7.3 handling of '' in integer context