比如我在Users表中我想获取所有的UserName并以逗号分割:
UserName
admin
ceo
cto
...我想得到的结果是“admin,ceo,cto,...”。
在sql server 中我会这样处理:
declare @str = nvarchar(4000)
select @str = @str + UserName + ',' from Users但在oracle中该怎么处理呢????我是新手,救命啊!!!!!!!!!!!
UserName
admin
ceo
cto
...我想得到的结果是“admin,ceo,cto,...”。
在sql server 中我会这样处理:
declare @str = nvarchar(4000)
select @str = @str + UserName + ',' from Users但在oracle中该怎么处理呢????我是新手,救命啊!!!!!!!!!!!
select col1,wmsys.sys_concat(col2) from tableA
group by col1
2 where rownum<=10;WMSYS.WM_CONCAT(AREANAME)
------------------------------------------------------------------------浙江省,杭州市,上城区,下城区,江干区,拱墅区,西湖区,滨江区,萧山区,余杭区SQL>
10g前用sys_connect_by_path
cursor comma_cur is
select lname||fname from employee;
full_name varchar2(30);
begin
open comma_cur;
fetch comma_cur into full_name;
while comma_cur%found
loop
[color=#FF0000]dbms_output.put_line (full_name||','); fetch comma_cur into full_name;
end loop;
end;[/color]