Re: [BUGS] BUG #4916: wish: more statistical functions (median, percentiles etc)

From: David Fetter <david(at)fetter(dot)org>
To: Richard Neill <rn214(at)cam(dot)ac(dot)uk>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: [BUGS] BUG #4916: wish: more statistical functions (median, percentiles etc)
Date: 2009-07-12 15:53:50
Message-ID: 20090712155350.GE18589@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general

On Fri, Jul 10, 2009 at 11:37:46PM +0000, Richard Neill wrote:
>
> The following bug has been logged online:
>
> Bug reference: 4916
> Logged by: Richard Neill
> Email address: rn214(at)cam(dot)ac(dot)uk
> PostgreSQL version: 8.4
> Operating system: Linux
> Description: wish: more statistical functions (median, percentiles etc)

This really should go to the pgsql-general list, where I'm redirecting
follow-ups. :)

> Details:
>
> In addition to the existing aggregate functions (avg, stddev etc), it would
> be nice if postgres could return further information. For example, the
> quartiles, percentiles, and median.

You can get ntiles in 8.4 with the windowing functions. As to median,
it is very precisely defined...several different and incompatible
ways. Any ideas as to how to handle this?

> [mode would also be useful, as an explicit function, though we can get it
> easily enough using count(1) order by count desc].

You can get that with windowing functions, too. :)

> According to google, this has been a wish since at least year 2000
> for various people, but doesn't seem to be implemented.

Patches are welcome :)

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Pavel Stehule 2009-07-12 20:25:44 fix: plpgsql: return query and dropped columns problem
Previous Message Pavel Stehule 2009-07-12 15:28:58 fix: plpgsql: return query and dropped columns problem

Browse pgsql-general by date

  From Date Subject
Next Message Scott Bailey 2009-07-12 15:56:35 Re: xpath() subquery for empty array
Previous Message Pavel Stehule 2009-07-12 15:21:27 Re: Execute Immediate