Re: returning row numbers in select - Mailing list pgsql-general

From Randall Skelton
Subject Re: returning row numbers in select
Date
Msg-id E2662045-72E1-11D8-BD91-000393C92230@brutus.uwaterloo.ca
Whole thread Raw
In response to Re: returning row numbers in select  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: returning row numbers in select
Re: returning row numbers in select
List pgsql-general
>> Correction, I don't want to simply get the nth row, I want all rows
>> that are divisible by n.  Essentially, the timestamp is at a regular
>> interval and I want a way of selecting rows at different sampling
>> intervals.
>
> Couldn't you code this as a WHERE test on the timestamp?

That would be ideal as it is theoretically possible for there to be
missing rows due to sampling errors; nevertheless, a WHERE test doesn't
seem obvious to me.  Can you please post an example?  The time spacing
between rows is 1 second but I want my select statement to return rows
every 5 seconds (see marked lines below).  I've tried various interval
operations but I don't really understand how to relate the timestamp
and and the interval.

SELECT timestamp FROM test WHERE timestamp > '2004-02-02 04:15:00.00
+0' AND timestamp < '2004-02-02 04:15:10.00 +0' ORDER BY timestamp;

          timestamp
----------------------------
  2004-02-01 23:15:00.824-05  *
  2004-02-01 23:15:01.824-05
  2004-02-01 23:15:02.824-05
  2004-02-01 23:15:03.824-05
  2004-02-01 23:15:04.824-05
  2004-02-01 23:15:05.824-05  *
  2004-02-01 23:15:06.824-05
  2004-02-01 23:15:07.824-05
  2004-02-01 23:15:08.824-05
  2004-02-01 23:15:09.824-05
  2004-02-01 23:15:10.824-05  *
  ...

Thanks,
Randall


pgsql-general by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: Re: symbolic links for 7.4.2
Next
From: Tom Lane
Date:
Subject: Re: returning row numbers in select