0

I have a query were im returning a 3 columns

ID    NUMBER    LETTER
123    1        a
124    2        b
123    1        c
123    1        d

what I want to do is have a row like

ID    NUMBER    LETTER
123    1        a,c,d

when I the ID and NUMBER column is the same is one value and t

Doc Holiday
  • 9,928
  • 32
  • 98
  • 151

1 Answers1

3

In Oracle 11g, you can use the LISTAGG() function:

select id,
  number,
  listagg(letter, ', ') within group(order by id, number) as letter
from yourtable
group by id, number;

See SQL Fiddle with Demo

Taryn
  • 242,637
  • 56
  • 362
  • 405