Re: BUG #2994: avg() calculates wrong on Interval-type

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-bugs(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Frank F(dot) Burmo" <fburmo(at)online(dot)no>
Subject: Re: BUG #2994: avg() calculates wrong on Interval-type
Date: 2007-02-12 23:20:22
Message-ID: 200702130020.23365.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Tom Lane wrote:
> "Frank F. Burmo" <fburmo(at)online(dot)no> writes:
> > The following avg()-call gives me a result of: "2 days,
> > 27:53:49.359573"... which must be wrong. There are only 24 hours in
> > a day.
>
> That's a false premise. Days and hours/minutes/seconds are
> independent components of an interval.

I don't understand how it does the computation then. None of his input
data contains hour/minute/second components in excess of 24 hours, so
to arrive at 27-some hours it must have pulled over some days.

Moreover, my system thinks that the average of '1 day 12 hours' and '8
hours' is 22 hours, and also that the average of '2 days' and '3 days'
is 2 days and 12 hours, so it does make the assumption that 1 day = 24
hours.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Anthony Taylor 2007-02-12 23:59:31 BUG #2996: to_char( timestamp, 'DD-Mon-YYYY HH24:MI:SS.MS' ) reports .1000 ms
Previous Message Tom Lane 2007-02-12 21:14:49 Re: BUG #2994: avg() calculates wrong on Interval-type