Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Concatenate multi rows from one table in DB2

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
kregen

New User


Joined: 16 Mar 2006
Posts: 18

PostPosted: Fri Apr 20, 2007 4:46 pm    Post subject: Concatenate multi rows from one table in DB2
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

Site Director


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

PostPosted: Fri Apr 20, 2007 7:31 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm
This topic is locked: you cannot edit posts or make replies. DB2 query Using Recursion, Converting... smilewithashu2 DB2 3 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us