Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id BAF86B632CE for ; Sat, 4 Jun 2011 16:16:12 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 05391-06 for ; Sat, 4 Jun 2011 19:16:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from eastrmfepo103.cox.net (eastrmfepo103.cox.net [68.230.241.215]) by mail.postgresql.org (Postfix) with ESMTP id C460DB632CB for ; Sat, 4 Jun 2011 16:16:05 -0300 (ADT) Received: from eastrmimpo01.cox.net ([68.1.16.119]) by eastrmfepo103.cox.net (InterMail vM.8.01.04.00 201-2260-137-20101110) with ESMTP id <20110604191600.ZBLM32559.eastrmfepo103.cox.net@eastrmimpo01.cox.net> for ; Sat, 4 Jun 2011 15:16:00 -0400 Received: from slacker.ja10629.home ([68.106.109.147]) by eastrmimpo01.cox.net with bizsmtp id rvFz1g00c3Ar1Vg02vG0yN; Sat, 04 Jun 2011 15:16:00 -0400 X-CT-Score: 0.00 X-CT-RefID: str=0001.0A020206.4DEA8470.002C,ss=1,re=0.000,fgs=0 X-CT-Spam: 0 X-Authority-Analysis: v=1.1 cv=+17iLFnYzMxkmuYPR7uG0c+juKqqE9nfhYUeb3IIowk= c=1 sm=1 a=z1TLwsU0kBEA:10 a=rNODZyWf3PYA:10 a=PjkiJtDTOQ4A:10 a=ZcFhQy0-F_sA:10 a=kj9zAlcOel0A:10 a=sXZhTwfwSKhiTs9RzZXpNQ==:17 a=P6M1L9rJAAAA:8 a=_3YUE-UqHVL2_8jyK5sA:9 a=D3relD4OTFIfot2GrDwA:7 a=CjuIK1q_8ugA:10 a=V_iEmhlNuOsA:10 a=sXZhTwfwSKhiTs9RzZXpNQ==:117 X-CM-Score: 0.00 Authentication-Results: cox.net; none Received: from wcuddy by slacker.ja10629.home with local (Exim 4.72) (envelope-from ) id 1QSwKF-0004GG-OK for pgsql-sql@postgresql.org; Sat, 04 Jun 2011 15:15:59 -0400 Date: Sat, 4 Jun 2011 15:15:59 -0400 From: lists-pgsql@useunix.net To: pgsql-sql@postgresql.org Subject: Re: selecting records X minutes apart Message-ID: <20110604191559.GA16254@slacker.ja10629.home> References: <20110603195253.GE1324@slacker.ja10629.home> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201106/9 X-Sequence-Number: 35475 On Sat, Jun 04, 2011 at 11:45:08AM +0000, Jasen Betts wrote: > On 2011-06-03, lists-pgsql@useunix.net wrote: > > > > ID TS (HH:MM) > > ------------------- > > 0 20:00 > > 0 20:05 > > 0 20:10 > > 1 20:03 > > 1 20:09 > > > > > > Does my question make sense? > > no, why is (1,20:04) excluded, but (0,20:05) included? > both records are 5 minutes from the newest. Jasen, (1,20:04) is excluded because it's timestamp is less than 5 minutes from the previous record with the same ID (1,20:03), (0,20:05) is included for the opposite reason. Let me restate my requirement again with a little more detail. 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. I hope that helps. Thanks again, Wayne