这两天咋都是这个问题啊。SQL> select * from a;I NAM - --- 1 aa 1 bb 1 cc 2 xx 2 yy 3 zz 3 mm select max(substr((sys_connect_by_path(name,',')),2)) cola from ( select id,name, rownum rnum, row_number() over(partition by id order by id) rn1 from a ) start with rn1=1 connect by rnum-1=prior rnum group by id ;--------------------------------------------------------------------------------aa,bb,cc xx,yy zz,mm
- ---
1 aa
1 bb
1 cc
2 xx
2 yy
3 zz
3 mm select max(substr((sys_connect_by_path(name,',')),2)) cola
from (
select id,name,
rownum rnum,
row_number() over(partition by id order by id) rn1
from a
)
start with rn1=1
connect by rnum-1=prior rnum
group by id
;--------------------------------------------------------------------------------aa,bb,cc
xx,yy
zz,mm
http://blog.csdn.net/kinglht