Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Random Numbers in PL/SQL

Re: Random Numbers in PL/SQL

From: <bob_jenkins_at_my-dejanews.com>
Date: Wed, 28 Apr 1999 20:18:35 GMT
Message-ID: <7g7qel$plf$1@nnrp1.dejanews.com>


In article <7g3t28$8lr$1_at_nnrp1.dejanews.com>,   youngsod_at_my-dejanews.com wrote:
> Sorry if this has been asked before, but I need some help.
>
> I have a table with around 27000 records at present and growing.
>
> The primary key is a varchar2(7) ID 1234567 , not created sequentially.
>
> I need to be able to get a random sample of 100 records from the table.
>
> Any ideas ?
>
> Douglas
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>

Try this:

  select * from emp where dbms_utility.get_hash_value(dump(rowid),0,100)<10;

There's also a dbmsrand.sql package in Oracle8. And if you're before that, there's http://ourworld.compuserve.com/homepages/bob_jenkins/rnd.sql , but neither of them can be used in the where-clause of a query until Oracle8i.

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Wed Apr 28 1999 - 15:18:35 CDT

Original text of this message

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