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 > Informix > Split rows into one row as comma delimited string

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-27-09, 06:30
tyaramis tyaramis is offline
Registered User
 
Join Date: Mar 2005
Posts: 6
Rows into one row as comma delimited string

HI All

Is it possible to generate such a result set with a query in informix?

With my existing query I am getting this resultset:

SystemName Numbers
A 111
A 222
B 123
B 356
B 777
C 888

and I would like get a result set like this:

SystemName Numbers
A 111;222
B 123;356;777
C 888

Thanks alot in advance.

Last edited by tyaramis; 11-27-09 at 06:44. Reason: Title was wrong.
Reply With Quote
  #2 (permalink)  
Old 11-27-09, 09:42
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
Not in a query. What you want to do should be done in a stored function or simply in a programming environment. For instance if you're working on a UNIX system and this query is executed in dbaccess you could redirect the Output To-pipe:
Code:
awk '{a[$1] = (length(a[$1]) > 0) ? a[$1] ";" $2 : a[$1] $2}END{for(i in a)print i, a[i]}'
Regards,
Hans
Reply With Quote
  #3 (permalink)  
Old 11-30-09, 12:04
ceinma ceinma is offline
Registered User
 
Join Date: Apr 2007
Location: Jundiai / SP - Brasil
Posts: 311
using SPL (Stored Procedure) , yes you can.. but depending the amount of data , the performance will no be good.

If you need to much this and use IDS >= 9.40, can write a function in C, and probably your process speed will be much better.
__________________
________________________________________
César Inacio Martins
Jundiai / SP - Brasil
http://www.imartins.com.br/informix - em Português
http://www.imartins.com.br/informix - English (translated by Google).
________________________________________
Reply With Quote
Reply

Tags
informix, sql

Thread Tools
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