Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f52DoHE06266 for ; Sat, 2 Jun 2001 09:50:17 -0400 (EDT) (envelope-from ler@lerctr.org) Received: (from ler@localhost) by lerami.lerctr.org (8.12.0.Beta7/8.12.0.Beta7/20010318/$Revision: 1.22 $) id f52DoDsJ028927 for pgsql-sql@postgresql.org; Sat, 2 Jun 2001 08:50:13 -0500 (CDT) (envelope-from ler) Date: Sat, 2 Jun 2001 08:50:12 -0500 From: Larry Rosenman To: PostgreSQL SQL List Subject: Re: trying to summarize into a new table by time... Message-ID: <20010602085012.A28751@lerami.lerctr.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20010602051258.A18140@lerami.lerctr.org> User-Agent: Mutt/1.3.18i X-Mailer: Mutt http://www.mutt.org/ X-Archive-Number: 200106/13 X-Sequence-Number: 3216 * Larry Rosenman [010602 05:17]: > Where we group into six hour groupings. > > I came up with the following: > > insert into traffic_summary > select asn,protocol, > cast(sum(pkts_src) as float) as pkts_src, > cast(sum(pkts_dst) as float) as pkts_dst, > cast(sum(bytes_src) as float) as bytes_src, > cast(sum(bytes_dst) as float) as bytes_dst, > cast(sum(secs_src) as float) as secs_src, > cast(sum(secs_dst) as float) as secs_dst, > min(early) as early, > max(late) as late > from traffic > where early >= '2001-01-01 00:00:00' and > early <= '2001-01-02 05:59:59' > GROUP BY asn,protocol; > I *THINK* I can change the GROUP BY to add date_trunc('hour',early) and get what I want to the hour. How can I get 6 hours? -- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 972-414-9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749