Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 5ABC6475943 for ; Sat, 1 Jun 2002 06:35:08 -0400 (EDT) Received: from druid.net (druid.net [216.126.72.98]) by postgresql.org (Postfix) with ESMTP id 5FB824758EF for ; Sat, 1 Jun 2002 06:35:07 -0400 (EDT) Received: by druid.net (Postfix, from userid 1000) id 651FC1B01; Sat, 1 Jun 2002 06:35:11 -0400 (EDT) Content-Type: text/plain; charset="iso-8859-1" From: "D'Arcy J.M. Cain" Reply-To: pgsql-sql@PostgreSQL.org To: "Ricardo Javier Aranibar =?iso-8859-1?q?Le=F3n?=" Subject: Re: problem with sql Date: Sat, 1 Jun 2002 06:35:10 -0400 X-Mailer: KMail [version 1.3.2] References: In-Reply-To: Cc: pgsql-sql@PostgreSQL.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <20020601103511.651FC1B01@druid.net> X-Archive-Number: 200206/3 X-Sequence-Number: 7968 On May 31, 2002 08:32 pm, Ricardo Javier Aranibar León wrote: > I think that my head will exploit, I can't resolve this problem and I hope > that somebody can help me. Can't have that. It might leave a mess in our nice, clean mailing list. :-) > My data base stores the statistics of ping that are generated every minute. > For a day I have 1440 registers, I want to group them every 5 minutes. > I use this: > hb#select sum(tras), sum(lost), avg(min), avg(prom), avg(max) from simon > where fecha='2002-05-31' and ip='166.114.214.22' and hora between '00:00' > and '00:05'; > > This work for five register, but i like that this function as a bucle every > 5 minutes for example in the next report the interval of hora between > '00:05' and '00:10' the next hora between '00:10' and '00:15'.....until > arrive hora between '23:55' and '24:00' Well, how accurate does this have to be? Are you just trying to see some statisticle correlations or do you need to actually count each bing once and only once for some sort of accounting purposes. I assume the former in which case the following may be what you are looking for.. ...where hora between 'NOW'::timestamp - '5 MINUTE'::interval and 'NOW. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.