vendredi 30 mars 2018

adding column in Oracle SQL table that is random sample from another column/table

I have a preexisting table (MYORIGTABLE) in SQL and I would like to add a column which is a random sample from a column in another table (RANDNUM10). The other table is a 1 column sample of random numbers I've predetermined and would like to sample from; column name is RANDVAL. I've tried the following

select (select randval from (SELECT randval FROM RANDNUM10 ORDER BY dbms_random.value) where rownum=1) as mynum from MYORIGTABLE

But unfortunately this just gives me the same random number which was sampled from RANDNUM10 repeated for the entire length of MYORIGTABLE. How can I perform the sampling so that every line of MYORIGTABLE gets a newly generated sample?

Thanks, Christie




Aucun commentaire:

Enregistrer un commentaire