Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

weighted random value (1-10) e.g.3 will be 50 % of records

835234Oct 6 2011 — edited Oct 6 2011
Hello,

i need to generate random values into my table. For the simplification, lets say that i need to generate values in range from 1 to 10. For this there is a lot of ways.

e.g. UPDATE test_number SET random_value = round (dbms_random.value (1,10))

But what I need is something like weighted random values. I need random values to be inserted into column, but I need e.g. 3 to be inserted more times than other values e.g. if i have 100 rows i want to have 3 in 50 random rows

Do you have any idea how to achieve it?

Thanks a lot for any help or reply !
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 3 2011
Added on Oct 6 2011
4 comments
618 views