Oraclewm_concat columns are separated by commas (,).

Source: Internet
Author: User
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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.