"average" time

From: Ulf Mehlig <umehlig(at)uni-bremen(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: "average" time
Date: 2000-10-26 15:24:27
Message-ID: 14840.19627.816771.43293@pandora3.vmnet.localnet
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Hello out there,

an ignorant's question: can I/how can I create an aggregate that
performs this operation on a group of timestamp values:

select some_column,
min(timest)+(max(timest)-min(timest))/2
from mytable
group by some_column;

that is, an aggregate which calculates the point half way between the
minimum and the maximum of the time series? I would like to use it
like this (substitute something appropriate for "median", I don't have
an idea how to call it):

select some_column, median(timest)
from mytable
group by some_column;

Any suggestions appreciated!
Regards,
Ulf

--
=======================================================================
Ulf Mehlig <ulf(dot)mehlig(at)zmt(dot)uni-bremen(dot)de>
Center for Tropical Marine Ecology/ZMT, Bremen, Germany
-----------------------------------------------------------------------

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Eisentraut 2000-10-26 15:48:25 Re: plperl
Previous Message Stephan Szabo 2000-10-26 15:22:15 Re: Query Problem