Filtering data based on timestamp

From: Panos Kassianidis <pkas(at)inaccessnetworks(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Filtering data based on timestamp
Date: 2006-02-07 15:40:35
Message-ID: 43E8BF73.9000802@inaccessnetworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello everybody,

I am building a data logging application and I am facing the following
problem. I have a table which holds timestamp-value pairs for a recorded
variable. I would like to be able to select a range of values between
a starting
and an ending timestamp but also specify an interval over which values
should be averaged. For example let's say I have 180 values recorded
over the last 3 hours
(1 per minute)
and I would like to retrieve values recorded in the last 2 hours but
with an interval of 5 minutes, which means that my query should return
one tuple for every 5 tuples in the table and the value of this tuple
should be an average of 5 values.
Does anyone have any clue how I can make this query? I have though
about somehow grouping the tuples with group by and use the AVG
function but the tuples don't have anything in common to be grouped by.

Thank you very much in advance.

Panos

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2006-02-07 15:49:31 Re: Filtering data based on timestamp
Previous Message Vic Rowan 2006-02-07 15:14:08 Re: problem referencing an attrib which is not unique