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: Help with Random Samples!

Re: Help with Random Samples!

From: Brian Tkatch <SPAMBLOCK.Maxwell_Smart_at_ThePentagon.com.SPAMBLOCK>
Date: Wed, 14 Feb 2001 22:08:33 GMT
Message-ID: <3a8b014f.72468406@news.alt.net>

On Wed, 14 Feb 2001 18:19:56 GMT, Scott Weiner <sweiner_at_infinata.com> wrote:

>I need to be able to get a random sample of some number of records out
>of a table. For instance the user may say "give me 300 random records".
>
>Assuming the table has 300+ records in it I need to RANDOMLY bring back
>300 records.
>
>Any idea how I do this in Oracle 8i? I tried using the Sample function
>but that seems to only provide an approximation through a percentage. I
>need to get back exact numbers of random samples.
>
>Thanks!
>
>- Scott
>

Do you have a sequential primary key?

If so, you may consider using the DBMS_RANDOM package to generate a randiom number, and you can pull that record out of the database. Do that inside of a loop that executes 300 times.

Brian Received on Wed Feb 14 2001 - 16:08:33 CST

Original text of this message

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