Hi,
Consider Table Product which consists of two columns with following records as shown below :
Product_ID Product_Name
001 IPhone
001 IPhone
001 Watch
001 Laptop
001 Laptop
Expected Output :
Product_ID Product_name
001 IPhone, Watch, Laptop
However, when I am trying to achieve output using XMLAGG() Function,
Command :
select rtrim(xmlagg(xmlelement(e,product_name,', ').extract('//text()') order by product_name).getclobval(),', ') "Product_Name" from Product;
Output Appearing using XMLAGG() Function :
Product_ID Product_Name
001 IPhone, IPhone, Watch, Laptop, Laptop
I need output which can eliminate IPhone and Laptop records appearing twice for same product. id "001".
Can you please advice how to fix this issue.
Thanks for understanding in advance.