Re: a ramdom sort select (again)
Posted in 2000
No, even if the random numbers were duplicated as the temp table was being created, and you ordered by those random numbers during the select from the temp table, you still wouldn't select the same record twice. There's just two (or more) records with the same value in the column ordered by. But if you used a big enough range, duplicates would be unlikely, while with a random fetch with a scroll cursor, you have to have the range of the random numbers equal to the number of records in the set. ART KAGEL, BLOOMBERG/ NEW YORK wrote: > > Or just keep track of the random rownums already visited in the SCROLL > CURSOR and get another random number if a duplicate shows up. You would > have the same duplicate problem trying to assign random numbers to the > fetched rows anyway. > > Art S. Kagel > > ----- Original Message ----- > From: Colin McGrath <cmm@trac3000.ueci.com> > At: 5/ 4 13:54 > > > 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 > > -- 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