Re: [GENERAL] returning row numbers in select

2004-03-15 Thread Steve Crawford
On Wednesday 10 March 2004 12:25 pm, Randall Skelton wrote: > Is there a way to return an integer row number for a query? Note > that there may be a large number of rows so I would rather not have > joined selects... Well...if your result has a unique column you can do something like this: ste

Re: [GENERAL] returning row numbers in select

2004-03-10 Thread Bruno Wolff III
On Wed, Mar 10, 2004 at 17:25:49 -0500, Randall Skelton <[EMAIL PROTECTED]> wrote: > > 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

Re: [GENERAL] returning row numbers in select

2004-03-10 Thread Tom Lane
Randall Skelton <[EMAIL PROTECTED]> writes: >> 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 ex

Re: [GENERAL] returning row numbers in select

2004-03-10 Thread Bernard Clement
Maybe by using a sequence and a function. The sequece to generate the row number. The a function 1) to reset the sequence and 2) to perform a select with the first column nextval(seq) and the column the timestamp However, I am a newbie with PostgreSQL and I am not sure it this will work cor

Re: [GENERAL] returning row numbers in select

2004-03-10 Thread Tom Lane
Randall Skelton <[EMAIL PROTECTED]> writes: > 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 W

Re: [GENERAL] returning row numbers in select

2004-03-10 Thread Chris
> I to return a sequential row number beginning at 1? > > i.e. > > row| timestamp > ---+ > 1 2004-02-01 23:15:00.824-05 > 2 2004-02-01 23:15:01.824-05 > 3 2004-02-01 23:15:02.824-05 > ... > > My reason for wanting row numbers is so I can use a 'MOD(row_

[GENERAL] returning row numbers in select

2004-03-10 Thread Randall Skelton
Is there a way to return an integer row number for a query? Note that there may be a large number of rows so I would rather not have joined selects... For a rather simple query: SELECT timestamp from test WHERE timestamp > '2004-02-02 04:15:00.00 +0' ANDtimestamp < '2004-02-02 04:15:10.00