If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > SQL Help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-25-04, 12:16
ykc ykc is offline
Registered User
 
Join Date: Feb 2004
Posts: 2
SQL Help

I need help in concatenating the results of an SQL into a single string.
Is there an aggregate grouping function on string in DB2?

Ex:

SQL: Select FirstName from Employee

This returns all the rows in the Employee table with just the FirstName Column. Instead of multiple rows, I want to return just one string with all the values of the rows concatenated and seperated by ",". Can this be done in DB2 procedure or SQL?

Thanks in advance

ykc
Reply With Quote
  #2 (permalink)  
Old 02-25-04, 13:29
Damian Ibbotson Damian Ibbotson is offline
Padawan
 
Join Date: Jun 2002
Location: UK
Posts: 525
This should give you a start...

create single field from many records
Reply With Quote
  #3 (permalink)  
Old 02-25-04, 14:09
ykc ykc is offline
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks Damian,
Unlike in the thread you forwarded, I am doing this in a procedure and I can declare a temporary variable and loop through the result rows and concatenate the values to this temporary variable. I am just not familiar with SQL syntax to do this. I am thinking there should be a simpler program to accomplish this. Any help is greatly appreciated

Thanks
ykc
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On