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 > Results in one line

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Apr 2012
Posts: 16
Results in one line

Hello all

Is it possible to get all the lines of a query next to each other? I.e. if a query normally returns:
A;
B;
C;
D;

Is it possible to display this result as:
A;B;C;D

Thanks and regards

S. BASU
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Aug 2008
Posts: 125
__________________
---------------------------------
www.sqlserver-dba.com
www.dba-db2.com
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 3,224
There are (at least) three ways, like ...
Combine values from different records using comma
Quote:
If you are using DB2 9.7 fixpack 4 for LUW,
you may want to use LISTAGG function.

Otherwise, you can use XMLGROUP or XMLAGG function instead of LISTAGG function.

Another way would be recursive-common-table-expression.

You would find some examples by searching this forum with those keywords.
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