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 -> Re: Randomizing resultssets

Re: Randomizing resultssets

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: 2000/08/06
Message-ID: <398D01FE.4BCC@yahoo.com>#1/1

davidai_at_shopnow.com wrote:
>
> I want to write a stored procedure that returns a set of 6 records
> randomly selected from a table. What is the best way of implementing
> this?
>
> David
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

Not spectacularly efficient, but you can do

select *
from (

   select *
   from table
   order by <x> )
where rownum < 7

where <x> is the random number generator function of your choice..

HTH

-- 
===========================================
Connor McDonald
http://www.oracledba.co.uk

We are born naked, wet and hungry...then things get worse
Received on Sun Aug 06 2000 - 00:00:00 CDT

Original text of this message

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