Re: a ramdom sort select (again)
Posted in 2000
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Well, this might not be what is wanted if the random order desired should not be allowed to return the same row multiple times. Just a random order of the rows, but only one return of each row? You'd have to save a random number and each row to a temp table, then select from the temp table, ordering by the random number, right? Art S. Kagel wrote: > > pgcs@pgcs.com wrote: > > > > You can implement this in 4GL , ESQLC etc by using prepared > > statements. > > Vivek is correct. To be specific you need to open a SCROLL cursor and > FETCH ABSOLUTE n where n is a random number from 1 to the number of rows > returned by the OPEN in the sqlca structure. > > Art S. Kagel > > > Vivek Chaudhary > > > > On Wed, 26 Apr 2000 18:54:35 BST, "Obnoxio The Clown" > > <obnoxio@hotmail.com> wrote: > > > > > > > >From: Daniel Esquerre Fernandez <desquerre@sil.edu.pe> > > >> > > >> Anyone know how make a select of many rows y random order, i e some > > >>like select * from mytable order by random > > > > > >What version? I guess you could probably do this with 9.x > > >________________________________________________________________________ > > >Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com > > > > > -- Colin McGrath cmm@trac3000.ueci.com Raytheon Constructors Inc. (215) 422-4144 Philadelphia, PA, USA Any opinions I state are my own and not necessarily those of my employer
Then just keep track of random rownums already visited and reject any values that you have already fetched once. You would have the same problem with duplicates assigning a random number to the rows in the temp table, anyway. Art S. Kagel Colin McGrath wrote: > > Well, this might not be what is wanted if the random order desired should not > be allowed to return the same row multiple times. Just a random order of > the rows, but only one return of each row? You'd have to save a random > number and each row to a temp table, then select from the temp table, > ordering by the random number, right? > > Art S. Kagel wrote: > > > > pgcs@pgcs.com wrote: > > > > > > You can implement this in 4GL , ESQLC etc by using prepared > > > statements. > > > > Vivek is correct. To be specific you need to open a SCROLL cursor and > > FETCH ABSOLUTE n where n is a random number from 1 to the number of rows > > returned by the OPEN in the sqlca structure. > > > > Art S. Kagel > > > > > Vivek Chaudhary > > > > > > On Wed, 26 Apr 2000 18:54:35 BST, "Obnoxio The Clown" > > > <obnoxio@hotmail.com> wrote: > > > > > > > > > > >From: Daniel Esquerre Fernandez <desquerre@sil.edu.pe> > > > >> > > > >> Anyone know how make a select of many rows y random order, i e some > > > >>like select * from mytable order by random > > > > > > > >What version? I guess you could probably do this with 9.x > > > >________________________________________________________________________ > > > >Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com > > > > > > > > > > -- > Colin McGrath cmm@trac3000.ueci.com > Raytheon Constructors Inc. (215) 422-4144 > Philadelphia, PA, USA > Any opinions I state are my own and not necessarily those of my employer