Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Sequence numbers / ordered queries
Hi
I have a query which returns data sorted by some item using the ORDER BY clause. Additionally I would like to assign an increasing number to each row, so that the first row gets the value x, the second row the value x+1. These numbers should be applied to the sorted results, so that the row with the lowest item also has the lowest assigned number. This value should be stored in the database and should be updated according to the amount of rows fetched, so the number should be set to x+n after the query, if n rows were returned.
Such increasing numbers usually are achieved by using sequences. Unfortunately sequences can't be used in ordered queries. I didn't find a suitable way to achieve the same result with another technique, other than creating a new table containing this number and to select/update this value by hand.
I wonder whether anyone has a more elegant solution to this problem?
bye
--
Sam Jordan
Received on Fri Apr 23 1999 - 05:36:54 CDT