Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to generate specified Random
I guess you really want a random pick. First of all, you'd need a random
generator. See
http://www.oracle.com/st/products/features/free_plsql_utilities.html to get
the function Rand.
Next:
select name
from doctors
where rowid in
( select rowid
from doctors where specialism = 'Cancer' order by Rand
Bad thing is that all doctors having specialism Cancer are selected in the subquery, even though only one is needed. If you're temped to skip the subselect, note that you can not use
where rownum = xxx
(unless xxx = 1) as rownum is only incremented when a row is selected. So, using = instead of < will result in no rows at all.
Arjan. Received on Fri Aug 14 1998 - 00:00:00 CDT