Results 1 to 4 of 4

Thread: Random

  1. #1
    Join Date
    Feb 2004
    Posts
    16

    Unhappy Unanswered: Random

    Is there a select Random command that i can use ??

    say i have 8 rows in my Top_Res table

    how do i randomly select one of them in SQL ??

  2. #2
    Join Date
    Feb 2004
    Location
    Minneapolis
    Posts
    2
    Theres no easy way to do this that I know of. You can refer to records in your table through your primary key, or use the record id supplied by oracle. But you will have to find a way to randomly select one of the values. You might try dbms_random.random to get a random number, and then use that to select one of your values somehow (either by determining odd or even, or dividing it by something? This is just a though, I've never done this myself.

    select dbms_random.random() from dual;

  3. #3
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    SELECT employee_id, department_id FROM employees SAMPLE(10);

  4. #4
    Join Date
    Jan 2004
    Location
    North Haven, CT
    Posts
    110

    Re: Random

    Originally posted by innes_22
    Is there a select Random command that i can use ??

    say i have 8 rows in my Top_Res table

    how do i randomly select one of them in SQL ??
    you might have missed tony's post.

    again:

    select * from
    (select * from table1 order by dbms_random.random())
    where rownum = 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •