Aggregate time data on half hour interval - Mailing list pgsql-general

From Lars
Subject Aggregate time data on half hour interval
Date
Msg-id Pine.BSF.4.10.10007192132170.9230-100000@maximillion.sscsinc.com
Whole thread Raw
Responses Re: Aggregate time data on half hour interval
List pgsql-general
I am looking for a way to aggregate timestamped data on a half hour
interval, not just by the hour or minute. Suppose I have a table composed
of:

    Date   |   Time   | Data
-----------+----------+------
1999-12-19 | 10:00:00 | 76
1999-12-19 | 10:15:00 | 72
1999-12-19 | 10:30:00 | 77
1999-12-19 | 10:45:00 | 71
1999-12-19 | 11:00:00 | 74
1999-12-19 | 11:15:00 | 78

I can aggregate by the hour without problem:
SELECT Date, date_trunc('hour', Time) AS HOUR, SUM(Data)
FROM Table
GROUP BY Date, HOUR;

What I would like to do though is aggregate by each half hour or maybe
even 20 minutes. Does anyone know a good way to do this?

Thanks in advance,

-Lars




pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] Re: PRIMARY KEY & INHERITANCE (fwd)
Next
From: Chris Bitmead
Date:
Subject: Re: [HACKERS] Re: PRIMARY KEY & INHERITANCE (fwd)