Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Randomizing resultssets
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 worseReceived on Sun Aug 06 2000 - 00:00:00 CDT