-1

may be this type of question has been already asked, but i couldn't find it... So i need a little help... Thanks...

Suppose i have a table TABLE1 as...

----------------------
stdcode  |    value  | 
----------------------
1        |     AA    |
----------------------
1        |     AA    |
----------------------
1        |     AC    |
----------------------
1        |     BB    |
----------------------
2        |     BA    |
----------------------
2        |     BD    |
----------------------

and i want to write a sql query which prints the result as...

1 AA;AA;AC;BB
2 BA;BD

DB2 equivalent syntax also required....

Ashwani Kumar Rahul
  • 776
  • 1
  • 6
  • 14

1 Answers1

1

You are looking for group_concat():

select stdcode, group_concat(value separator ';') as values
from table1
group by stdcode;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786