[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
执行结果: