
March 12th, 2003, 02:50 PM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 3
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
random sql selections in oracle.
These are the 3 ways i've found to do random selections in oracle. If there's a better way... SOMEONE tell me.
1) NO WHERE CLAUSE, 10%:
select * from my_table sample(10)
The other two aren't so pretty...
2) WHERE CLAUSE, no order clause. When using ado, you can do a recordcount * 10% and just print that many records:
select my_table.*
from my_table
[WHERE CLAUSE]
order by mod(DBMS_RANDOM.Random,50)+50
3) WHERE CLAUSE, order clause. Then, either through an outer query or when running through a loop, just print the records that have RANDOM less than 10
select mod(DBMS_RANDOM.Random,50)+50 as RANDOM,
my_table.*
from my_table
[WHERE CLAUSE]
order by page,revision
|