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

2
  • Possible duplicate Commented Jun 21, 2013 at 15:49
  • What version of Oracle? Commented Jun 21, 2013 at 15:59

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.