title: Eliminate duplicates using Oracle LISTAGG function
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/11510870/listagg-in-oracle-to-return-distinct-values">LISTAGG in oracle to return distinct values</a>  </p>
  </blockquote>
  
  
  
  <p>I am using Oracle LISTAGG function but within my list of returned names I actually would like to eliminate duplicates and only return distinct values.</p>
  
  <p>The query I have is something like this:</p>
  
  <pre><code>select a.id,
         a.change_id,
         LISTAGG(b.name, ',') WITHIN GROUP (ORDER BY b.name) AS "Product Name", 
  from   table_a a,
         table_b b
  where  a.id = 1
  and    b.change_id = c.change_id
  group by a.id, a.change_id
  </code></pre>
  
  <p>At the moment, it is returning (just showing one record):</p>
  
  <pre><code>1    1   NameA, NameA, NameB, NameC, NameD, Name D
  </code></pre>
  
  <p>What I would like returned is:</p>
  
  <pre><code>1    1   NameA, NameB, NameC, Name D
  </code></pre>