Aggregate working on ordered data

From: Christoph Dalitz <christoph(dot)dalitz(at)hs-niederrhein(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Aggregate working on ordered data
Date: 2002-12-19 09:40:31
Message-ID: 20021219104031.7c4ab598.christoph.dalitz@hs-niederrhein.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Lee Kindness 2002-12-19 09:46:25 trouble caused by change in 7.3 handling of '' in integer context
Previous Message Conxita Marín 2002-12-19 09:34:15 Re: SELECT EXTRACT doesn't work with variables?