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