3

I have two tables, let's call them PERSON and NAME.

 PERSON
  person_id
  dob

 NAME
  name_id
  person_id
  name

And let's say that the NAME table has data like:

name_id  person_id  name
1        1          Joe
2        1          Fred
3        1          Sam
4        2          Jane
5        2          Kim

I need a query (Oracle 10g) that will return

name_id   names
1         Joe, Fred, Sam
2         Jane, Kim

Is there a simple way to do this?


Update:

According to the article that figs was kind enough to provide, starting in 9i you can do:

SELECT wmsys.wm_concat(dname) departments FROM dept;

For this example, the answer becomes:

SELECT name_id,  wmsys.wm_concat(name) from names group by name_id
Rizwan
  • 103
  • 4
  • 24
chris
  • 36,094
  • 53
  • 157
  • 237

1 Answers1

0

The short answer is to use a PL/SQL function. For more details, have a look in this post.

Community
  • 1
  • 1
Mike McAllister
  • 1,479
  • 2
  • 12
  • 15