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!

Reg : String Aggregation --

915396Oct 31 2012 — edited Oct 31 2012
Hi Experts,

I'm doing a string aggregation but not able to get Distinct values aggregated.
Ex -
with xx as(
  select 'A' a from dual union all
  select 'B' a from dual union all
  select 'C' a from dual union all
  select 'C' a from dual union all
  select 'D' a from dual 
)
select rtrim(xmlagg(xmlelement(e,x.a||',')).extract('//text()'),',') from xx x;
gives
A,B,C,C,D
Expected o/p :
A,B,C,D
Is there any other String Aggregation techniques which can achieve this?
Please suggest ideas.

Thanks in Advance.
Ranit B.

Oracle Database version - 11.2.0.2.0
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 28 2012
Added on Oct 31 2012
6 comments
256 views