使用自定义函数:
create or replace function zdy(bm varchar2) return varchar2 is
begin
declare
c1 is select col2 from tablename where col1=bm;
str varchar2(500);
tmpstr varchar2(20);
begin
str:='';
open c1;
loop
fetch c1 into tmpstr;
exit when c1%notfound;
str:=str||tmpstr;
end loop;
close c1;
return str;
end;
end;sql>select distinct col1,zdy(col1) from tablename
create or replace function zdy(bm varchar2) return varchar2 is
begin
declare
c1 is select col2 from tablename where col1=bm;
str varchar2(500);
tmpstr varchar2(20);
begin
str:='';
open c1;
loop
fetch c1 into tmpstr;
exit when c1%notfound;
str:=str||tmpstr;
end loop;
close c1;
return str;
end;
end;sql>select distinct col1,zdy(col1) from tablename
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货