Re: Random question

From: <sw_at_weinerfamily.org>
Date: Fri, 16 Feb 2001 13:49:25 GMT
Message-ID: <3A8D2F7A.E0339F6A_at_weinerfamily.org>


The problem is this doesn't guarantee I get back a unique and complete set of records. Duplicates are unnacceptable and the dataset is so large that if I need to check for duplicates on each record selected - it could take hours.

Horizon wrote:

> Hi,
>
> We have a method can be generate a random number using dbms_random (say a).
> Get the count of the total number of records (say b). Use the function c :=
> (a mod b ). Then select the zth record. The mod function is used to ensure
> that the probability of selecting every record is uniform( i.e 1/z).
> Cheers,
>
> trandt_at_yahoo.com
> More Oracle scripts and links please visit http://www.geocities.com/trandt
>
> ---------------------------
>
> "Scott Weiner" <sweiner_at_infinata.com> wrote in message
> news:3A8ACB15.28F0E7DE_at_infinata.com...
> > 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
> >
> >
> > --
> > _______________________________
> > Scott Weiner
> > Vice President of Product Development
> >
> > Infinata, Inc.
> > 400 Massachusetts Avenue, Suite 2
> > Arlington, MA 02474
> >
> > T: 781.643.3856
> > F: 781.643.2294
> > sweiner_at_infinata.com
> > www.infinata.com
> >
> > The information contained in this e-mail communication and any attached
> > documentation may be privileged, confidential or otherwise protected
> > from
> > disclosure and is intended only for the use of the designated
> > recipient(s).
> > If the reader or recipient of this communication is not the intended
> > recipient, or an employee or agent of the intended recipient who is
> > responsible for delivering it to the intended recipient, you are hereby
> > notified that any review, dissemination, distribution, copying or other
> > use
> > of this communication is strictly prohibited. If you have received this
> >
> > communication in error, please immediately notify us by return e-mail
> > and
> > promptly delete the original electronic e-mail communication and any
> > attached documentation. Receipt by anyone other than the intended
> > recipient
> > is not a waiver of any work-product privilege.
> >
> >
Received on Fri Feb 16 2001 - 14:49:25 CET

Original text of this message