title: How to use stuff function in Oracle
body: <p>I asked the stuff function in Oralce question several months ago and would like to revisit this question. The problem was when using the WM_CONCAT function (in Oracle), the result included the (,) in the front or before the field I wanted to stuff.</p>
  
  <p>I googled to find a solution for this but had no success so far. What should I need to include in the WM_CONCAT function in order to remove the extra empty string for the field I'd like to stuff? </p>
  
  <p>I have some sample records below</p>
  
  <pre><code>CREATE TABLE #TEMP
  (
    COMPANY VARCHAR (50),
    ID INT,
    PRODUCT VARCHAR(50)
  )
  
  INSERT INTO #TEMP VALUES ('APPLES', '123', 'IPHONE4')
  INSERT INTO #TEMP VALUES ('APPLES', '123', 'IPHONE4S')
  INSERT INTO #TEMP VALUES ('APPLES', '123', 'IPHONE5')
  
  
  INSERT INTO #TEMP VALUES ('SAMSUNG', '124', 'GALAXY S2')
  INSERT INTO #TEMP VALUES ('SAMSUNG', '124', 'GALAXY S3')
  INSERT INTO #TEMP VALUES ('SAMSUNG', '124', 'GALAXY S4')
  
  
  INSERT INTO #TEMP VALUES ('NOKIA', '125', 'C5-02')
  INSERT INTO #TEMP VALUES ('NOKIA', '125', 'C5-03')
  INSERT INTO #TEMP VALUES ('NOKIA', '125', 'C5-04')
  </code></pre>
  
  <p>When running this query it produces as</p>
  
  <pre><code>SELECT
  COMPANY,
  ID,
  WM_CONCAT(PRODUCT) AS PRODUCT, --STUFF PRODUCT COLUMN
  FROM
  (
     SELECT
     COMPANY,
     ID,
     PRODUCT
     FROM #TEMP
   )
  GROUP BY COMPANY, ID
  
  
  COMPANY     ID      PRODUCT
  APPLES      123     IPHONE4, IPHONE4S, IPHONE5
  SAMSUNG     124     ,GALAXY S2, GALAXY S3, GALAXY S4
  NOKIA       125     ,C5-02, C5-03, C5-04
  </code></pre>