Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to generate specified Random
>Assuming you've got a numeric identifier on your doctors file, it's
>simply a matter of
>
> select .....
> from doctors
> where doctor_id = rand_max(2000)
This, of course, relies on having 2000 (or more) doctors. Otherwise your query might return no row at all. So, you need to know the number of doctors before you can use this query.
>If you haven't got a numeric id, you'll have to use rownum ( but this
>will be inefficient )
>
> select ....
> from doctors
> where rownum = rand_max(2000)
This won't work, as rownum is only incremented for each row that is actually retrieved. So, you can only use the equal sign for rownum = 1. For all other numbers you'll have to use rownum < value.
Try, for example:
select table_name
from my_tables
where rownum = 2;
Arjan. Received on Mon Aug 17 1998 - 00:00:00 CDT
![]() |
![]() |