Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Sequence numbers / ordered queries

Sequence numbers / ordered queries

From: Sam Jordan <sjo_at_spin.ch>
Date: Fri, 23 Apr 1999 10:36:54 +0000
Message-ID: <37204D46.2060CD6D@spin.ch>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US