Question: Let's say I have a table with two columns:

```
id | value
----------
 1 | 101
 2 | 356
 3 |  28

```

I need to randomly permute the value column so that each id is randomly assigned a new value from the existing set {101,356,28}. How could I do this in Oracle SQL?

It may sound odd but this *is* a real problem, just with more columns.

Answer: 
You can do this by using `row_number()` with a random number generator and then joining back to the original rows:

```
with cte as (
      select id, value,
             row_number() over (order by id) as i,
             row_number() over (order by dbms_random.random) as rand_i
      from table t
     )
select cte.id, cte1.value
from cte join
     cte cte1
     on cte.i = cte.rand_i;

```

This guarantees a permutation (i.e. no original row has its value used twice).

EDIT:

By the way, if the original `id`s are sequential from 1 and have no gaps, you could just do:

```
select row_number() over (order by dbms.random) as id, value
from table t;

```
An Option : `select * from x_table where id = round(dbms_random.value() * 3) + 1;` [Here 3 is the number of rows in your random data table and I am assuming that id is incremental and unique?]

I'll think of other options.