create or replace function get(p_id in varchar2) 
return varchar2 is
Result varchar2(100);
cursor rad_cursor is
        select pid from a
        where id=p_id ;
v_count Number;  
begin
v_count:=0;
   for v_sor in rad_cursor loop
     if v_count=0 then
       Result:=v_sor.pid;
       v_count:=v_count+1;
     else
      Result:=Result||','||v_sor.pid;
     end if;
    end loop; 
return(Result);
end get_book;
/select id,get(id) from a group by id;

解决方案 »

  1.   

    要用到虚表:
    select id ,pid 壹 into a1 from tablename where pid='1';
    select id ,pid 贰 into a2 from tablename where pid='2';
    select id ,pid 叁 into a3 from tablenaem where pid='3';select a.pid 编号,壹,贰,叁 into #Result from a,a1,a2,a3
    where a.pid=a1.pid and a1.pid=a2.pid and a2.pid=a3.pid还有简便的方法,我也不太记的啦,想起来在交流
    这个的话适合你要把行换成列的这个行的类别不多,可以也可以先建立好表结构
    然后
    update tablename
      

  2.   

    My qq is 23703867.
    if you have time ,we can study together!
    Thank you!
      

  3.   

    beckhambobo(beckham) 是正确的,
    听斑竹的没错!!
      

  4.   

    我也觉得beckhambobo(beckham) 的可行,我替你是一下吧
      

  5.   

    select id,max(decode(pid,1,pid,null))||','
             ||max(decode(pid,2,pid,null))||','
             ||max(decode(pid,3,pid,null)) pid
    from a
    group by id;