Bruno Wolff III <bruno@wolff.to> writes:
> Neil Conway <neilc@samurai.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