pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeremiah Elliott <geek00@gmail.com>
To: pgsql-sql@postgresql.org
Subject: avg(interval)
Date: Mon, 26 Jun 2006 16:22:11 -0500
Message-ID: <17eca7f50606261422m77395b89ufb713720defb8b42@mail.gmail.com> (raw)

I am getting some really strange query output. I am trying to average an
interval. The problem is that the interval average is sometimes
returning more than 24 hours for the average.

query:
select avg(scan_date -  backflush_date) as time_diff,
substring(pt_article, 1, 5) as clan, sum(qty) as units
from carton_master
join outbound on master_number = master_id
join pt_mstr on product = pt_part  where
scan_date::date  between '2006-06-01'::date and '2006-07-01'::date
and  substring(pt_article, 1, 5) = '*2420'
group by clan

output:
4 days 33:48:13.994333   *2420   25



however if i don't average them here is what i get:
query:
select (scan_date -  backflush_date) as time_diff,
substring(pt_article, 1, 5) as clan
from carton_master
join outbound on master_number = master_id
join pt_mstr on product = pt_part  where
scan_date::date  between '2006-06-01'::date and '2006-07-01'::date
and  substring(pt_article, 1, 5) = '*2420'

output:
"7 days 22:24:50.62311";"*2420"
"9 days 22:21:02.683393";"*2420"
"23:21:35.458459";"*2420"
"4 days 22:47:41.749756";"*2420"
"3 days 06:05:59.456947";"*2420"



which should average to just over nine days -
Assuming I am not missing something huge here. I tend to think its a bug
in avg(interval) postgres function.

I am running postgres 8.1.3 on 32bit suse

Thanks
Jeremiah Elliott



view thread (6+ messages)  latest in thread

Message-ID: <17eca7f50606261422m77395b89ufb713720defb8b42@mail.gmail.com>
Permalink:  ../17eca7f50606261422m77395b89ufb713720defb8b42@mail.gmail.com/
Also on:    postgresql.org/message-id/17eca7f50606261422m77395b89ufb713720defb8b42@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: geek00@gmail.com
  Subject: Re: avg(interval)
  In-Reply-To: <17eca7f50606261422m77395b89ufb713720defb8b42@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox