1 Reply Latest reply: Oct 20, 2008 11:18 AM by Frank Kulash RSS

    concatenate column values into a row

    516217
      <p>


      Hi,
      </p>


      <p>


      Can any one please advise how to do this:
      </p>


      <p>






      I have the column data as below:
      </p>


      <p>


      <strong>C1 </strong><strong>C2

      </strong>1 a

      1 b

      1 c

      2 d

      2 e
      </p>


      <p>


      I need the values to be displayed as
      </p>


      <p>






      <strong>C1 </strong><strong>C2

      </strong>1 a; b; c;

      2 d; e;



      I need this to be done in a simple select command not a procedure. Please help.







      Thanks

      </p>

      Edited by: Rummy on Oct 20, 2008 12:05 PM
        • 1. String Aggregate
          Frank Kulash
          Hi,

          That's called string aggregation.

          There are several solutions on [asktom.oracle.com|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2196162600402]

          I recommend the first solution on that page, the user-defined function STRAGG. You can copy it verbatim once for all, and then use it everywhere, like this:
          SELECT    c1
          ,         STRAGG (c2)
          FROM      table_x
          GROUP BY  c1;
          In Oracle 10 (and up), you may already have a function named WM_CONCAT available, which is equivalent to STRAGG.