Re: How to generate specified Random

From: Arjan van Bentem <avbentem_at_DONT-YOU-DAREdds.nl>
Date: 1998/08/17
Message-ID: <6r9mt3$379$1_at_newton.a2000.nl>#1/1


>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 CEST

Original text of this message