A   1           A   1,2,3
A   2           B   4 
A   3    变成   C   5,6 
B   4           D    
C   5
C   6
D      我想实现上面那样的效果
求ORACLE帝帮我写个通用的函数吧  

解决方案 »

  1.   

    A  1
    A  2
    A  3
    B  4
    C  5
    C  6
    D
    变成
    A  1,2,3
    B  4
    C  5,6
    D   
    这个样子上面乱掉了
      

  2.   

    select c1,wm_concat(c2) from t group by c1
      

  3.   

    我需要个通用的函数  数据库是ORACLE  9I的
      

  4.   

    看看版主的:http://topic.csdn.net/u/20100109/13/6a10c168-f190-4766-b838-adbf03c4ac7b.html
      

  5.   

    参考这个:select deptno, ltrim(MAX(sys_connect_by_path(ename, ',')), ',') str
      from (select ename,
                   deptno,
                   row_number() over(partition by deptno order by ename) rn
              from emp) t
     start with rn = 1
    connect by prior rn = rn - 1
           and prior deptno = deptno
     group by deptno