各位大侠
在表t1中,有4个字段a,b,c,d
t1表中记录为:
          a        b        c        d
       2008-8-1  20080634  赵小波  3837594
       2008-8-1  20080634  赵小波  1111111
希望的查询结果为:          a        b        c               d
       2008-8-1  20080634  赵小波    3837594 1111111小弟在线等!!!

解决方案 »

  1.   

    select a,b,c,wmsys.replace(wm_concat(d),',',' ') from t1 group by a,b,c;
      

  2.   

    select a,b,c,replace(wmsys.wm_concat(d),',',' ') from t1 group by a,b,c;上面写错
      

  3.   

    我用的是9i数据库,没有wmsys.wm_concat函数呀?
      

  4.   

    那就麻烦点用Sys_Connect_By_Path
    [code=SQL]select a,b,c,substr(max(Sys_Connect_By_Path(d,',')),2) d from(
       select a,b,c,d,row_number()over(partition by a,b,c order by d)rn
         from t1)t
       start with t.rn=1
       connect by t.rn=prior t.rn-1 and
          t.a=prior t.a and t.b=prior t.b
          and t.c=prior t.c
       group by a,b,c   code]
      

  5.   

    select a,b,c,substr(max(Sys_Connect_By_Path(d,',')),2) d from(
       select a,b,c,d,row_number()over(partition by a,b,c order by d)rn
         from t1)t
       start with t.rn=1
       connect by t.rn=prior t.rn-1 and
          t.a=prior t.a and t.b=prior t.b
          and t.c=prior t.c
       group by a,b,c   
      

  6.   

    修改下select a,b,c,ltrim(max(Sys_Connect_By_Path(d,' '))) d from(
       select a,b,c,d,row_number()over(partition by a,b,c order by d)rn
         from t1)t
       start with t.rn=1
       connect by t.rn=prior t.rn+1 and
          t.a=prior t.a and t.b=prior t.b
          and t.c=prior t.c
       group by a,b,c   
      

  7.   

    谢谢 wildwave
    good job!!!