title: How to remove duplicate values from a aggregate list when using LISTAGG() in oracle SQL?
body: <p>I have created a table:</p>
  
  <pre><code>Grade FName LName-
  
  A     JOHN     M
  
  A     JOE      M
  
  A     JOAKIM   M
  </code></pre>
  
  <p>Used Listagg() to get a concatenated aggregation of Fname &amp; Lname using the query:</p>
  
  <pre><code>SELECT GRADE,listagg(st_name || ';' || st_last_name, ';')
          within group ( order by st_name) as names FROM STUDENTS GROUP BY GRADE;
  </code></pre>
  
  <p>The output that I get is:</p>
  
  <pre><code>GRADE    Name
  
  A     JOAKIM;M;JOE;M;JOHN;M
  
  B        BROAD;M
  
  C        KEVIN;M;SEEHO;M
  </code></pre>
  
  <p>I want to keep the only one 'M' in the name column and want to discard the other M's. Please provide me with any suggestions on how to accomplish this.Please do not be specific to this question. Thanks! </p>
  
  <p>Example:
  KEVIN;M;SEEHO;M should be  KEVIN;M;SEEHO, JOAKIM;M;JOE;M;JOHN;M should be JOAKIM;M;JOE;JOHN and so on...</p>