有表结构
A      B
-----------------
1      a
1      b
1      c如何才能一个sql语句将其展现为下列记录1      a,b,c谢谢大家,想了很久,找不到好的办法!

解决方案 »

  1.   

    declare
      v_count int;
      v_column  varchar2(10);
      v_totol varchar2(200);
      cursor mycur is select  distint a from table ; 
    begin
      for i in mycur loop
         v_count :=0;
         v_totol :='';
         v_column :='';
         select count(1) into v_count from a where a.a =i.a;
         for j in 1..v_count loop
            select b into v_column from a where a.a =i.a;
            v_totol :=v_totol+',' + v_column;
         end loop
         dbms_out.put_line(i.a||' '||v_total);
      end loop;
    end    笨方法,期待抛砖引玉哦 
    ^_^ 
      

  2.   

    谢谢!但我想用一个sql语句就能写出来,不知能否赐教
      

  3.   

    10 G
    select a,wmsys.wm_concat(b) b
    from a
    group by a
      

  4.   

    9I
    select a,substr(max(sys_connect_by_path(b,',')),2) b,
    from (select a.*,row_number()over(partition by a order b) rn from a ) 
      group by a 
      start with rn=1 
    connect by rn-1=prior rn and a=prior a