On Sat, Jun 4, 2011 at 12:15 PM, <lists-pg...@useunix.net> wrote: > I want to > select records grouped by ID, ordered by timestamp, in ascending order so I'm > starting with the oldest, that are at least X minutes apart.
Here my guess: SELECT id, ts FROM Yourtable AS A AND NOT EXISTS ( SELECT * FROM Yourtable AS B WHERE B.id = A.id AND B.ts > A.ts - INTERVAL '5 MINUTES' AND B.tx < A.ts ) ORDER BY id, ts; -- Regards, Richard Broersma Jr. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql