Oracle - Concatenate several columns in one cell separeted by newline

April 8, 2013

In order to concatenate the values of the same column across several records do:

_   select replace( wm_concat(<FIELD_NAME>), ‘,', chr(13))
   from <TABLE_NAME>;

_
Examples:

  • Add all distinct values in the same cell separated by “:”

         select distict(wm_concat(<FIELD_NAME>), ‘,', ‘:')
         from <TABLE_NAME>;

  • Add all values in the same cell separated by a new line “chr(13)”

_         replace(wm_concat(<FIELD_NAME>), ‘,', chr(13))_