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: <sw_at_weinerfamily.org>
Date: Fri, 16 Feb 2001 14:00:52 GMT
Message-ID: <3A8D3225.661D4B2A@weinerfamily.org>

I do, however records are deleted so I will need to run more often than 300 if no records are returned. In addition, while my example is 300, the sample size could be 300 million. Also, since I must have a unique set of sampled records, each fetch would have to be compared to the set so far to ensure they are distinct. This process could take hours or perhaps days for a large sample.

Any suggestions on how to do this efficiently?

Thank you.

Brian Tkatch wrote:

> 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 Fri Feb 16 2001 - 08:00:52 CST

Original text of this message

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