下面是双色球红球随机(平均分布)选号的语句,希望给楼主作参考.
-- 其中tmp1为33个红球,tmp2为需要选号的注数.
with tmp1 as (select level as num from dual connect by level <= 33),
tmp2 as (select level as id from dual connect by level <= 2)
--
select
c.id as rn,
substr(sys_connect_by_path(c.num,','),2) as res
from
(select
d.id,d.num
from
(select
b.id, a.num,
row_number()over(partition by b.id order by dbms_random.random) as rn
from tmp1 a, tmp2 b) d
where d.rn <= 6)c
where level = 6
connect by level <= 6
and prior c.num < c.num
and prior c.id = c.id
[ 本帖最后由 szusunny 于 2010-11-15 11:49 编辑 ]
|