cruel
Programmer
- Aug 6, 2001
- 131
I need to select a given number of random records. I have done this before, about 4 or 5 years ago, I forgot the function name? Anyone? Thanks
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
select r
from ( select rownum r
from all_objects
order by dbms_random.value)
where rownum <= 6;
R
----------
35809
44910
37879
13011
6428
17288
6 rows selected.
SQL> /
R
----------
14144
31970
24823
8509
43047
32094
6 rows selected.
select model,qty
from ( select model,qty
from model where model = 'A'
order by dbms_random.value)
where rownum <= 2
union
select model,qty
from ( select model,qty
from model where model = 'B'
order by dbms_random.value)
where rownum <= 2