From: Joe <dev@freedomcircle.net>
To: Erik Jones <erik@myemma.com>
Cc: Aaron Bono <postgresql@aranya.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Jeremiah Elliott <geek00@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: avg(interval)
Date: Mon, 26 Jun 2006 23:20:26 -0400
Message-ID: <44A0A3FA.4010404@freedomcircle.net> (raw)
In-Reply-To: <44A09CB6.8080102@myemma.com>
References: <17eca7f50606261422m77395b89ufb713720defb8b42@mail.gmail.com>
<23243.1151357823@sss.pgh.pa.us>
<44A05BD4.60900@freedomcircle.net>
<bf05e51c0606261753r68d5b2b3s1021fdc0a382614@mail.gmail.com>
<44A09CB6.8080102@myemma.com>
Erik Jones wrote:
> Well, the query is working ok numerically, but should the answer really
> be reported as 4 days and 33 hours?
Well, the original poster didn't provide the table schema or PG version,
but on PG 8.0.3 both with intervals or with differences between
timestamps, the query appears to work OK:
test=> select * from x;
t
-----------------
7 days 22:24:00
9 days 22:21:00
23:21:00
4 days 22:47:00
3 days 06:05:00
(5 rows)
test=> select avg(t) from x;
avg
-----------------
5 days 09:47:36
(1 row)
test=> select * from x2;
t
---------------------
2006-06-07 22:24:00
2006-06-09 22:21:00
2006-05-31 23:21:00
2006-06-04 22:47:00
2006-06-03 06:05:00
(5 rows)
test=> select avg(t - '2006-5-31 0:0'::timestamp) from x2;
avg
-----------------
5 days 09:47:36
(1 row)
Joe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@freedomcircle.net, erik@myemma.com, postgresql@aranya.com, tgl@sss.pgh.pa.us, geek00@gmail.com
Subject: Re: avg(interval)
In-Reply-To: <44A0A3FA.4010404@freedomcircle.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox