Oracle - Concatenate several columns in one cell separeted by newline

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))

Comments

Popular posts from this blog

Hibernate - HibernateException: createQuery is not valid without active transaction