随笔-42  评论-12  文章-0  trackbacks-0

代码:SQL> var str varchar2(30)SQL> exec :str := 'abc123def321a1'

PL/SQL 过程已成功完成。

 

1 select max(replace(sys_connect_by_path(ch, '/'), '/')) num

2 from (
3 select ch, rn - min(rn) over(partition by rn - rownum) rn, rn-rownum grp

4 from (
5 select substr(:str, rownum, 1) ch, rownum rn

6 from dual connect by rownum <= length(:str)
7 ) where ch between '0' and '9'
8 ) start with rn = 0

9 connect by rn - 1 = prior rn and grp = prior grp

10 group by grp

11* order by grp

SQL> /

NUM-------------------------------------------------------

123

321

1

 

SQL>

 

posted on 2007-10-19 14:11 tianjuchuan 阅读(1181) 评论(0)  编辑 收藏 引用 所属分类: sql
只有注册用户登录后才能发表评论。