Oraclewm_concat function, used for column-to-row conversion. This article will detail the application of this function by commas (,).
Oracle wm_concat function, used for column-to-row conversion, separated by commas (,) This article will detail the application of this function
[SQL]
The Code is as follows:
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 ('department 1', 1 );
Insert into wlbtest2 values ('department 2', 2 );
Select deptID, wm_concat (username) username, 'department '| deptID deptName from wlbtest1 group by deptID
Execution result: