0

I have a table like this

-----------
UID | NAME
-----------
1   | 'AAA'
1   | 'BBB'
2   | 'AAA'
3   | 'BBB'
3   | 'CCC'
3   | 'DDD'

I want to write a query to show the result like this:

-----------
UID | NAME
-----------
1   | 'AAA','BBB'
2   | 'AAA'
3   | 'BBB','CCC','DDD'

Is it possible to do that ?

Mureinik
  • 297,002
  • 52
  • 306
  • 350
codentest
  • 13
  • 1
  • 6

1 Answers1

0

and above offer the LISTAGG function:

SELECT   uid, LISTAGG(name, ',') WITHIN GROUP (ORDER BY name)
FROM     my_table
GROUP BY uid
user2672165
  • 2,986
  • 19
  • 27
Mureinik
  • 297,002
  • 52
  • 306
  • 350