0

table 1 is my current table. newtable is what needs to be insert into.

Here's the example: Table 1

a
b
c
d

newTable

a
a
a
a
b
b
b
b
b
c
c
c
c
c
d
d
d
d
Matt
  • 14,906
  • 27
  • 99
  • 149
  • 2
    So far you have an Oracle answer and a MySQL answer. You might want to tag the actual database this needs to be done in. – Nick.Mc Sep 16 '14 at 23:58
  • i have the answer. thanks! Use a random function: SELECT FLOOR(RAND()*(6-4)+4). then put an insert statement in a loop. – user1376261 Sep 17 '14 at 13:34

2 Answers2

0

Try this in Oracle:

SELECT x, LEVEL from myTable t
        CONNECT BY LEVEL <= ROUND(DBMS_RANDOM.VALUE (4, 5))
and prior x = x
and prior sys_guid() is not null;    
Bulat
  • 6,869
  • 1
  • 29
  • 52
-1

If you are using mysql;

select * from table order by rand() limit 3
then
Insert it into new new table

Do it many times as you want.

You can follow previous post

Thank You,

Sameera

Community
  • 1
  • 1
Sameera Silva
  • 453
  • 2
  • 6
  • 13