Home > Database > Mysql Tutorial > oracle wm_concat 列转行 逗号分隔

oracle wm_concat 列转行 逗号分隔

WBOY
Release: 2016-06-07 17:55:59
Original
1431 people have browsed it

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

执行结果:



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template