合并具有随机值的列

时间:2015-09-21 10:04:52

标签: sql oracle

我试图生成一些随机值,但有些问题我不知道如何处理。我的SQL:

select * from 
(select round(dbms_random.value(1000000000,10000000000)) num from dual connect by rownum < X),
(Select round(dbms_random.value(1,5)) num1 from dual)

现在输出看起来:

1241511501  2
1515628080  2
1798442549  4
4061575813  2
5673495016  3
6582052088  5
7672299459  5
9360968960  5
9618384703  4

我想看看:

1241511501  5
    1515628080  5
    1798442549  5
    4061575813  5
    5673495016  5
    6582052088  5
    7672299459  5
    9360968960  5
    9618384703  5

当然是数字&#34; 5&#34;是可选的,它也应该是随机数。

1 个答案:

答案 0 :(得分:2)

试试这个:

select * from 
(select round(dbms_random.value(1000000000,10000000000)) num from dual connect by rownum < 10),
(Select round(dbms_random.value(1,5)) num1 from dual connect by rownum = 1)