Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Concat rows into single column

imran khanNov 11 2014 — edited Nov 12 2014

Hi All,

Oracle DB version: 11.2.0.2

  I have gone through previous posts and found the following query to concat rows into columns:

select rtrim(xmlagg(xmlelement(e, empno || ',')).extract('//text()').extract('//text()') ,',') empnos from emp
/
EMPNOS                                                                         
--------------------------------------------------------------------------------
7369,7499,7521,7566,7654,7698,7782,7788,7839,7844,7876,7900,7902,7934 

But what if I have duplicate records in the table emp? I want distinct records to be concatenated into a single column. Could you please help me out.

Thanks in advance.

Regards,

Imran Khan

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 10 2014
Added on Nov 11 2014
5 comments
1,961 views