Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id D951D1337B95 for ; Mon, 7 Feb 2011 17:35:26 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 93519-03 for ; Mon, 7 Feb 2011 21:35:20 +0000 (UTC) X-Greylist: delayed 00:23:41.660231 by SQLgrey-1.7.6 Received: from mail2.washoecounty.us (mail2.washoecounty.us [148.186.3.147]) by mail.postgresql.org (Postfix) with ESMTP id 448DA1337B8A for ; Mon, 7 Feb 2011 17:35:19 -0400 (AST) Received: from CIMTA ([148.186.120.91]) by mailpp2.washoecounty.us (8.14.4/8.14.4) with ESMTP id p17LBaHL009965 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Mon, 7 Feb 2011 13:11:36 -0800 Subject: Cumulative result with increment From: Shawn Tayler Reply-To: stayler@washoecounty.us To: pqsql list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Organization: Washoe County Regional Communications System Date: Mon, 07 Feb 2011 13:11:35 -0800 Message-ID: <1297113095.21916.76.camel@shop.telecom.co.washoe.nv.us> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 X-OriginalArrivalTime: 07 Feb 2011 21:11:35.0855 (UTC) FILETIME=[9A5D13F0:01CBC70B] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.2.15, 1.0.148, 0.0.0000 definitions=2011-02-07_06:2011-02-07, 2011-02-07, 1970-01-01 signatures=0 X-Proofpoint-Spam-Reason: safe X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201102/23 X-Sequence-Number: 35099 Hello, I am struggling with what is probably a simple problem but I am coming up blank. In the interest of full disclosure I am not a very savy programmer by any stretch. I have a table of data from an external source which contains numbers of events per operating group per hour per day, kind of like this: Group | events | duration | timestamp The Group, events, and duration (milliseconds) are all integers in char format. Timestamp is as stated. The records are at 1 hour increments. I need to sum the events and duration fields in 8 hour (shifts, mid to 8AM, 8AM to 4PM, etc). Id like the output to be in table format ala: Group | events | duration | date | shift ------+---------+------------+-----------+------- 100 | 26 |00:00:25.00 |2011-01-01 | Day=09 I have a function to convert the duration to an interval already and can make one to do the shift labeling. Its the rest that has me stumped. Any suggestions or direction? As always, your help is greatly appreciated. --=20 Sincerely, Shawn Tayler