日期:2014-05-16 浏览次数:21005 次
-------如果你查询出来的结果只有一行为连号,如果有多行非连号
SQL>
SQL> select rn
2 from (select rs, rs - row_number() over(order by 1) rn
3 from (select regexp_substr('12345', '\d', 1, rownum) rs
4 from dual
5 connect by rownum <= length('12345')))
6 group by rn
7 ;
RN
----------
0
SQL>
SQL> select rn
2 from (select rs, rs - row_number() over(order by 1) rn
3 from (select regexp_substr('15268', '\d', 1, rownum) rs
4 from dual
5 connect by rownum <= length('15268')))
6 group by rn
7 ;
RN
----------
2
3
-1
0
SQL>
------解决方案--------------------
正则表达式里,好像没有支持这种计算。
倒是可以帮着优化一下 连号的代码
where regexp_like( 4位号码 ,'^([[:digit:]])\1{3}$')