title: LISTAGG Oracle to join multiple rows with related records
body: <p>Anyone can help to join all the rows with the same Name with dash if the same string and if different join with pipe, I tried listagg function but I don’t know where to put the pipe.</p>
  <pre><code>SELECT NAME, ID
         LISTAGG(DIRECTION, '-') WITHIN GROUP (ORDER BY ID)
  FROM DUAL
  GROUP BY NAME, ID
  
  Data:
  
  NAME ID DIRECTION
  A    1  AAA-BBB
  A    2  BBB-CCC
  A    3  DDD-CCC
  B    1  ZZZ-AAA
  C    1  AAA-CCC
  C    2  CCC-BBB
  C    3  BBB-CCC
  
  Desired:
  NAME ID DIRECTION
  A    1  AAA-BBB-BBB-CCC|DDD-CCC
  B    1  ZZZ-AAA
  C    1  AAA-CCC-CCC-BBB-BBB-CCC
  </code></pre>