create table t(a varchar2(1));
insert into t values('a');
insert into t values('b');
insert into t values('c');
insert into t values('d');
insert into t values('e');
insert into t values('f');
commit;
SQL>
SQL> --1
SQL> select a from t;
A
-
a
b
c
d
e
f
6 개의 행이 선택되었습니다.
SQL>
SQL> --2
SQL> select
2 rownum-1 p,
3 rownum c,
4 a
5 from t;
P C A
---------- ---------- -
0 1 a
1 2 b
2 3 c
3 4 d
4 5 e
5 6 f
6 개의 행이 선택되었습니다.
SQL>
SQL> --3
SQL> select a,
2 sys_connect_by_path(a,'$') as m
3 from
4 (
5 select
6 rownum-1 p,
7 rownum c,
8 a
9 from t
10 )
11 start with c = 1
12 connect by prior c = p
13 ;
A M
-----------------------------------------------------------
a $a
b $a$b
c $a$b$c
d $a$b$c$d
e $a$b$c$d$e
f $a$b$c$d$e$f
6 개의 행이 선택되었습니다.
SQL>
SQL> --4. 결과
SQL> select replace(max(m),'$') as result
2 from (
3 select a,
4 sys_connect_by_path(a,'$') as m
5 from
6 (
7 select
8 rownum-1 p,
9 rownum c,
10 a
11 from t
12 )
13 start with c = 1
14 connect by prior c = p
15 );
RESULT
-----------------------------------------------------------
abcdef