dimanche 24 janvier 2016

Insert all values together with random values

I'm trying to insert data into 3 columns from another table T2. Insert random values from T2.DATA1 to T1.DATA1, and all values from T2 to columns DATA2 and DATA3. I have tried this query :

INSERT INTO T1 (DATA1, DATA2, DATA3)
SELECT (SELECT DATA1 FROM
(SELECT DATA1 FROM T2
ORDER BY dbms_random.value)
WHERE rownum = 1), DATA2, DATA3
FROM T2;

it return correct values to DATA2 and DATA3, but in DATA1 I have one generaated random value in all rows. How can I modify this query to have random value in every row ? T2 contains around 3000 rows.




Aucun commentaire:

Enregistrer un commentaire