Re: [GENERAL] median for postgresql 8.3

2010-11-17 Thread Pavel Stehule
2010/11/17 Dean Rasheed : > On 16 November 2010 17:37, Pavel Stehule wrote: >> Hello >> >> see >> http://okbob.blogspot.com/2009/11/aggregate-function-median-in-postgresql.html >> > > An 8.3-compatible way of doing it is: > > SELECT CASE WHEN c % 2 = 0 AND c > 1 THEN (a[1]+a[2])/2 ELSE a[1] END >

Re: [GENERAL] median for postgresql 8.3

2010-11-17 Thread Dean Rasheed
On 16 November 2010 17:37, Pavel Stehule wrote: > Hello > > see > http://okbob.blogspot.com/2009/11/aggregate-function-median-in-postgresql.html > An 8.3-compatible way of doing it is: SELECT CASE WHEN c % 2 = 0 AND c > 1 THEN (a[1]+a[2])/2 ELSE a[1] END FROM ( SELECT ARRAY(SELECT a FROM milro

Re: [GENERAL] median for postgresql 8.3

2010-11-16 Thread maarten
Hello Brent, well I said "using only the db" because this is a one time need and just wanted to avoid crufting around with calc, and doing 'manual' work. But that seems to be the fastest approach now. When it becomes a frequent need I'll probably end up doing what you suggest, or upgrade to 9.x,

Re: [GENERAL] median for postgresql 8.3

2010-11-16 Thread Brent Wood
Hi Maarten, The best way I know of to do this is not to do statistical queries "in" the DB at all, but use a stats capability embedded in your database, so they still appear to the user to be done in the db. I don't see how you can easily get the functionality you want without user defined func

Re: [GENERAL] median for postgresql 8.3

2010-11-16 Thread Pavel Stehule
Hello see http://okbob.blogspot.com/2009/11/aggregate-function-median-in-postgresql.html Regards Pavel Stehule 2010/11/16 maarten : > Hello everyone, > > I was doing some analysis of data to find average delays between some > timestamp values etc... > When the number of rows the average is com

[GENERAL] median for postgresql 8.3

2010-11-16 Thread maarten
Hello everyone, I was doing some analysis of data to find average delays between some timestamp values etc... When the number of rows the average is computed over is small, this can give distorted values. So I've obviously added a count column to see if the average represents much data. However,