Re: Returning Rows in Random Order

From: Spencer <spencerp_at_swbell.net>
Date: Wed, 7 Mar 2001 21:03:41 -0600
Message-ID: <pDCp6.96$J26.106365_at_nnrp3.sbc.net>


Another option, if it turns out that ROWID does not result in a "random enough" distribution, then create a function that takes ROWID as an input argument, and returns a random string, and use that in an ORDER BY clause...

SELECT
...
ORDER BY myrand(ROWID)

,
"Howard J. Rogers" <howardjr_at_www.com> wrote in message news:3aa69955_at_news.iprimus.com.au...
> But an order by rowid should do the trick.
>
> Not quite entirely random and fresh each time you run the select, but
 given
> that table data is in random order, the output with a 'group by rowid'
 will
> then be in the same random order.
>
> Regards
> HJR
>
>
>
>
> "jack straw" <sacque_at_yahoo.com> wrote in message
> news:985g4e$nub$1_at_linux1.netconx.de...
> > well, there is an index unfortunately :(
> >
> > "Happl Oberlin" <happl_at_mail.com> wrote in message
> > news:happl-F778E4.14173507032001_at_news.fu-berlin.de...
> > > In article <985a58$kl9$1_at_linux1.netconx.de>, "jack straw"
 <sacque_at_yahoo.com> wrote:
> > >
> > > >Is there a way to return rows from a SELECT statement in a random
 order?
> > > >I have found ways to do it in SQL server, but not in Oracle.
> > >
> > > If there is no ORDER BY or GROUP BY in the query and
> > > ORACLE does not use an index to retrieve the data,
> > > the rows are returned in random order.
> > >
> > > Greetings from Switzerland -- Gruesse aus der Schweiz
> > > Happl
> >
> >
>
>
>
Received on Thu Mar 08 2001 - 04:03:41 CET

Original text of this message