10

Possible Duplicate:
How can I combine multiple rows into a comma-delimited list in Oracle?

How can you produce a comma-separated values from list of return rows in SQL without creating a function? Need to remove duplicates and null or with 'None' as the value.

Example: select name from student;

The result :

         NAME         
        ------
        Zed
        Charlo
        None
        Charlo
        Dionn
        Ansay

Desired output :

              Name
             -------
             Zed,Charlo,Dionn,Ansay
Community
  • 1
  • 1
Ianthe
  • 5,559
  • 21
  • 57
  • 74

1 Answers1

21

http://sqlfiddle.com/#!4/9ad65/2

select 
  listagg(name, ',') 
    within group (order by id) as list 
from student
Jake Feasel
  • 16,785
  • 5
  • 53
  • 66