|
20#
SQL> with t as (select 0 n from dual union all select 1 from dual),
2 s(lvl,str) as (select 1,cast(n as varchar2(12)) from t
3 union all
4 select lvl+1,
5 s.str||t.n
6 from s,t
7 where lvl < 12),
8 p as (
9 select sum(case when mod(sum_minute,60)=0 then 1 else 0 end) res_cnt,
10 count(*) tot_cnt
11 from (
12 select str,15*12 + sum(case when substr(s.str,r,1) = 0 then -10 else 10 end) sum_minute
13 from s,(select level r from dual connect by level <=12) w
14 where lvl = 12
15 group by str)
16 ),
17 q (tot_cnt,res_cnt) as (
18 select tot_cnt,res_cnt from p
19 union all
20 select greatest(tot_cnt-res_cnt,res_cnt),least(tot_cnt-res_cnt,res_cnt)
21 from q
22 where tot_cnt<>res_cnt)
23 select p.res_cnt/q.tot_cnt||'/'||p.tot_cnt/q.tot_cnt as res
24 from q,p
25 where q.tot_cnt=q.res_cnt
26 /
RES
--------------------------------------------------------------------------------
683/2048 |
|