Reputation: 955
I have a table with 3 columns:
- PRIMARY_KEY
- AMOUNTS
- RAND_AMOUNTS
(all nulls)
I want the RAND_AMOUNTS
column to be populated with following formula:
AMOUNT*(0-100 random value)/100
So for example if the amount row let us suppose is 10 and the random value generated for the row is 10 then RAND_AMOUNT
should be 10 * 10 / 100 = $1
Upvotes: 3
Views: 20572
Reputation: 30838
Using:
dbms_random.value(lower-value-limit, upper-value-limit)
should do what you're looking for.
Upvotes: 2
Reputation:
dbms_random() is what you are looking for:
UPDATE the_table
SET rand_amount = (amount * dbms_random.value(0, 100) ) / 100
WHERE amount IS NOT NULL
Upvotes: 8