Thread: BUG #2767: Bug in avg(interval)

BUG #2767: Bug in avg(interval)

From
"Steffen Macke"
Date:
The following bug has been logged online:

Bug reference:      2767
Logged by:          Steffen Macke
Email address:      sdteffen@gmail.com
PostgreSQL version: 8.1.4
Operating system:   Windows XP
Description:        Bug in avg(interval)
Details:

select avg(interval) is occasionally returning wrong
values:

Example:

select avg(test) from problem

returns

1 day 25:15:30

while the correct result is

2 days 01:15:30

Here is a table with sample data used:

CREATE TABLE problem (
    test interval
);
COPY problem (test) FROM stdin;
1 day 20:39:28
4 days 00:02:53
1 day 00:03:01
2 days 02:08:34
01:33:34
3 days 07:05:35
\.

Re: BUG #2767: Bug in avg(interval)

From
Tom Lane
Date:
"Steffen Macke" <sdteffen@gmail.com> writes:
> select avg(test) from problem
> returns
> 1 day 25:15:30
> while the correct result is
> 2 days 01:15:30

This is not a bug; it's the result you're supposed to get.
But see justify_hours() if you want to fold up 24 hours to 1 day.

            regards, tom lane

Re: BUG #2767: Bug in avg(interval)

From
"Steffen Macke"
Date:
Tom,

> This is not a bug; it's the result you're supposed to get.
> But see justify_hours() if you want to fold up 24 hours to 1 day.

Thanks! I must have overlooked that in the documentation.
Sorry for this.

Regards,

Steffen