Get a delimited list in Oracle SQL
Posted: August 12, 2017 Filed under: Oracle Leave a commentThere are many times that I need to retrieve a delimited list in SQL and every time I have to track the solution down.
So here it is.
SELECT RTRIM ( rtrim(XMLAGG (XMLELEMENT (e, column_name || ',')).EXTRACT ('//text()'), ',') name FROM table_name;
Just to break this down a little
rtrim(XMLELEMENT (e, column_name || 'This is the delimiter')).EXTRACT ('//text()'), 'This is the delimiter')