IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Concatenate multi rows from one table in DB2


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kregen

New User


Joined: 16 Mar 2006
Posts: 21

PostPosted: Fri Apr 20, 2007 4:46 pm
Reply with quote

Hello,
i'm searching for a way to concat multi rows from 1 table.

Table
--------
1 a
1 b
1 c
1 d
2 a
3 a
3 b
4 x
5 z
6 1
6 2

i need a result like:

1, a, b, c, d
2, a
3, a, b
4 x
5 z
6 1, 2

is there a way in DB2 V7.2 OS/390 to get the resultset?

cu
kai
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Apr 20, 2007 7:31 pm
Reply with quote

Hello,

It would be rather easy if you use a cursor. . . .

With a cursor and an ordered by, you could get your result in one pass of the data.

Someone may post a complex query, but it may well be far more expensive to run.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top