From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Bruno Wolff III <bruno(at)wolff(dot)to> |
Cc: | Neil Conway <neilc(at)samurai(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: avg() for timestamp |
Date: | 2004-03-08 14:52:58 |
Message-ID: | 3550.1078757578@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Bruno Wolff III <bruno(at)wolff(dot)to> writes:
> Neil Conway <neilc(at)samurai(dot)com> wrote:
>> It seems to me the following should Just Work:
>> nconway=# select avg(a) from t1;
>> ERROR: function avg(timestamp without time zone) does not exist
> While there is a way to calculate an average timestamp, I don't think
> there is an easy way to do this automatically with say a polymorphic
> aggregate. You need to know that there is a related type interval that
> can be used to keep track of differences in timestamps and that can be
> added back to a timestamp at the end.
Given that this would be done with C code, I doubt we'd go to the
trouble of implementing it that way. We'd just cheat: add up the
numeric values of the timestamps and divide at the end. float8
makes a perfectly fine accumulator ;-)
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | GeGeZ | 2004-03-08 15:28:05 | question about API to b-tree in PG |
Previous Message | Shachar Shemesh | 2004-03-08 14:36:41 | one byte data type |