|
我第1行写错了,这回对了
with t as(select level-1 a from dual connect by level<=3),
a as(select * from(select replace(sys_connect_by_path(a,','),',')p --0白2黑1空
from t
where level=4
connect by prior dbms_random.value is not null
and level<=4)where regexp_count(p,'2')>regexp_count(p,'0')),
b as(select * from(select replace(sys_connect_by_path(p,','),',')b --0白2黑1空
,replace(sys_connect_by_path(substr(p,1,1),','),',')b1
,replace(sys_connect_by_path(substr(p,2,1),','),',')b2
,replace(sys_connect_by_path(substr(p,3,1),','),',')b3
,replace(sys_connect_by_path(substr(p,4,1),','),',')b4
from a
where level=2
connect by prior dbms_random.value is not null
and level<=2)where regexp_count(b1,'0')<2 and
regexp_count(b2,'0')<2 and
regexp_count(b3,'0')<2 and
regexp_count(b4,'0')<2 ),
b2 as(select * from(
select b.b||c.b b,
b.b1||c.b1 b1,
b.b2||c.b2 b2,
b.b3||c.b3 b3,
b.b4||c.b4 b4 from b,b c)
where regexp_count(b1,'2')>regexp_count(b1,'0') and
regexp_count(b2,'2')>regexp_count(b2,'0')and
regexp_count(b3,'2')>regexp_count(b3,'0')and
regexp_count(b4,'2')>regexp_count(b4,'0'))
select count(*) from b2; |
|