|
# 15
好吧,你们都口算,我还是暴力一把吧
SQL> with t as (select level -1 n from dual connect by level <=100),
2 d as (select lpad(n,2,'0') dd from t where n between 1 and 31 and substr(n,1,1)<> nvl(substr(n,2,1),'x')),
3 m as (select lpad(n,2,'0') mm from t where n between 1 and 12 and substr(n,1,1)<> nvl(substr(n,2,1),'x')),
4 y as (select lpad(n,2,'0') yy from t where n between 0 and 99 and substr(n,1,1)<> nvl(substr(n,2,1),'x')),
5 h as (select lpad(n,2,'0') hh from t where n between 0 and 23 and substr(n,1,1)<> nvl(substr(n,2,1),'x')),
6 i as (select lpad(n,2,'0') mi from t where n between 0 and 59 and substr(n,1,1)<> nvl(substr(n,2,1),'x')),
7 s (time_num) as (
8 select dd||mm||yy||hh||mi time_num
9 from d,m,y,h,i
10 where instr(dd,substr(mm,1,1))=0 and instr(dd,substr(mm,2,1))=0
11 and instr(dd||mm,substr(yy,1,1))=0 and instr(dd||mm,substr(yy,2,1))=0
12 and instr(dd||mm||yy,substr(hh,1,1))=0 and instr(dd||mm||yy,substr(hh,2,1))=0
13 and instr(dd||mm||yy||hh,substr(mi,1,1))=0 and instr(dd||mm||yy||hh,substr(mi,2,1))=0
14 )
15 select min(abs(a.time_num - b.time_num))
16 from s a,s b
17 where a.time_num <> b.time_num
18 /
MIN(ABS(A.TIME_NUM-B.TIME_NUM)
------------------------------
9 |
|