Re: [GENERAL] Statistical aggregates with intervals

2012-08-23 Thread Ondrej Ivanič
Hi, On 24 August 2012 07:39, Christopher Swingley wrote: > I don't know why, but you could convert 'interval' into something else > where all the functions work: > > CREATE OR REPLACE FUNCTION interval_to_seconds(interval) > RETURNS double precision AS $$ > SELECT (extract(days from $1) * 864

Re: [GENERAL] Statistical aggregates with intervals

2012-08-23 Thread Christopher Swingley
Thomas, On Wed, Aug 22, 2012 at 12:25 PM, Thomas Munro wrote: > I noticed that 'avg' works on 'interval', but 'stddev' and 'variance' don't: I don't know why, but you could convert 'interval' into something else where all the functions work: CREATE OR REPLACE FUNCTION interval_to_seconds(interv

[GENERAL] Statistical aggregates with intervals

2012-08-22 Thread Thomas Munro
Hi I noticed that 'avg' works on 'interval', but 'stddev' and 'variance' don't: hack=> create table test (start_time timestamptz, end_time timestamptz); CREATE TABLE hack=> insert into test values (now(), now() + interval '1 second'); INSERT 0 1` hack=> insert into test values (now(), now() + int