Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group