Re: SQL Question
Posted in 1998
Topics: Performance & Tuning
Some problems for your SQL. First, it cannot run on oracle, Seconds, if the sort key is not unique, the result may be wrong. Third, it may cause performance isuue if the table is large. On Mon, 22 Jun 1998, Volker B=F6=DF wrote: > js wrote: >=20 > > I am trying to figure out how to get a result set in which the row > > number is a column in the result set. For example, if I select n rows > > > > from a table, I need a column to contain 1 thru n. Optimally, the > > syntax needs to be ANSI standard SQL, but nearly any solution will do. > > > > Anyone have ideas? > > > > TIA > > JS >=20 > Hi,if the selected rows are sorted (for example by field 'sort_field') > the following will work: > 'select (select count (sort_field) +1 from table t1 where > t1.sort_field<t2.sort_field), .... from table t2 order by t2.sort_field' >=20 > Volker Boess >=20 >=20 >=20