Median/Quantile Aggregate

Поиск
Список
Период
Сортировка
Искать
От
David Orme
Тема
Median/Quantile Aggregate
Дата
в 12:48:41
Msg-id
50FA52F0-CB4B-4642-BA9B-F894EB4E0055@ic.ac.uk
Список
Дерево обсуждения
Median/Quantile Aggregate David Orme <d.orme@imperial.ac.uk>
Re: Median/Quantile Aggregate Tom Lane <tgl@sss.pgh.pa.us>
Re: Median/Quantile Aggregate Adam Witney <awitney@sgul.ac.uk>
Re: Median/Quantile Aggregate David Orme <d.orme@imperial.ac.uk>
Re: Median/Quantile Aggregate Sean Davis <sdavis2@mail.nih.gov>
Hi,

I know people have asked about this before but I can't find a working  
solution on the web - I've found code for specific instances of  
calculating medians but I need a general aggregate function for  
calculating medians, or more generally any given quantile.

The kind of thing I need to do is to be able to extract the median  
value from a table of 4 million rows, aggregating across more than  
50,000 grouping values - the sort of thing that is really easy to do  
for averaging:

SELECT grid_id, avg(rs) FROM behr_grid GROUP BY grid_id;

 From what I've seen on the web, I know this isn't trivial or  
necessarily fast but at the moment I'm reading the data out into  
something that calculates medians and then matching it back in and  
this doesn't feel particularly elegant!

Any suggestions gratefully received...

Thanks,
David



---------------------------------------
Dr. David Orme

Department of Biological Sciences
Imperial College London
Silwood Park Campus
Ascot, Berkshire SL5 7PY UK.

Tel: +44 (0)20 759 42358
Fax: +44 (0)20 759 42339
e-mail: d.orme@imperial.ac.uk


В списке pgsql-novice по дате отправления
От: Tom Lane
Дата:
От: Sean Davis
Дата:
Сообщение: Re: Median/Quantile Aggregate
FAQ