SQL Tricks

Tags:

SELECT contactID, RTRIM( xmlagg (xmlelement (c, subjectName || ‘,’) order by subjectName).extract (’//text()’), ‘,’ ) AS concatenated 
FROM tableExperts 
GROUP BY contactID; 

This will convert: 
contactID | subjectName 
5| 279 
5| 701 
5| 909 

To: 
5| 279,701,090