Re: [SQL] Filtering data based on timestamp

2006-02-07 Thread Richard Huxton
Panos Kassianidis wrote: Thanks very much for the answer. Could you also please tell me how am I supposed to write such a function? How is date_trunc implemented so that I can extend it? In C in SQL? I'd probably write it in plpgsql unless you need the speed. And where can I find its source c

Re: [SQL] Filtering data based on timestamp

2006-02-07 Thread Richard Huxton
Panos Kassianidis wrote: 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 ho

[SQL] Filtering data based on timestamp

2006-02-07 Thread Panos Kassianidis
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