oracle wm_concat 列转行 逗号分隔

[sql]

复制代码代码如下:


create table wlbtest1(
username varchar2(2),
deptID number
);
create table wlbtest2(
deptName varchar2(10),
deptID number
);
insert into wlbtest1 values ('a', 1);
insert into wlbtest1 values ('b', 1);
insert into wlbtest1 values ('c', 1);
insert into wlbtest1 values ('d', 2);
insert into wlbtest1 values ('e', 2);
insert into wlbtest1 values ('f', 2);
insert into wlbtest2 values ( '部门1' ,1);
insert into wlbtest2 values ( '部门2', 2);
select deptID, wm_concat(username) username,'部门'||deptID deptName from wlbtest1 group by deptID

执行结果:


本文链接:https://my.lmcjl.com/post/14883.html

展开阅读全文

4 评论

留下您的评论.