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'
AND    timestamp < '2004-02-02 04:15:10.00 +0';

where 'test' is

  Column   |           Type           | Modifiers
-----------+--------------------------+-----------
 timestamp | timestamp with time zone |
 value     | double precision         |
Indexes: table_timestamp

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_number, n)' to get the nth row from the table.

Cheers,
Randall


---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Reply via email to