Cumulative result with increment

From: Shawn Tayler <stayler(at)washoecounty(dot)us>
To: pqsql list <pgsql-sql(at)postgresql(dot)org>
Subject: Cumulative result with increment
Date: 2011-02-07 21:11:35
Message-ID: 1297113095.21916.76.camel@shop.telecom.co.washoe.nv.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

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.

--
Sincerely,

Shawn Tayler

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Steve Crawford 2011-02-07 22:13:30 Re: Cumulative result with increment
Previous Message Craig Ringer 2011-02-07 03:12:42 Re: PosgreSQL - TSQL2 question