selecting records X minutes apart - Mailing list pgsql-sql

From lists-pgsql@useunix.net
Subject selecting records X minutes apart
Date
Msg-id 20110603195253.GE1324@slacker.ja10629.home
Whole thread Raw
Responses Re: selecting records X minutes apart  (Kevin Crain <kevin.crain1@gmail.com>)
Re: selecting records X minutes apart  (Kevin Crain <kevin.crain1@gmail.com>)
Re: selecting records X minutes apart  (Kevin Crain <kevin.crain1@gmail.com>)
Re: selecting records X minutes apart  (Masaru Sugawara <pgsql@amail.plala.or.jp>)
Re: selecting records X minutes apart  (Masaru Sugawara <pgsql@amail.plala.or.jp>)
List pgsql-sql
I have a table that, at a minimum, has ID and timestamp columns.  Records
are inserted into with random IDs and timestamps.  Duplicate IDs are allowed. 

I want to select records grouped by ID, ordered by timestamp that are X minutes
apart. In this case X is 5.

Note, the intervals are not X minute wall clock intervals, they are X minute
intervals from the last accepted record, per-id.

For instance here is some sample input data:

ID    TS (HH:MM)
-------------------
0    20:00
1    20:03
1    20:04
0    20:05
1    20:05
0    20:08
1    20:09
0    20:10

I'd want the select to return:

ID    TS (HH:MM)
-------------------
0    20:00
0    20:05
0    20:10
1    20:03
1    20:09


Does my question make sense?

Thanks in advance,
Wayne


pgsql-sql by date:

Previous
From: "Greg Sabino Mullane"
Date:
Subject: Re: 9.0+ way of determining if a LISTEN channel has a backend listening?
Next
From: Kevin Crain
Date:
Subject: Re: selecting records X minutes apart