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 > put the result into list

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-21-10, 21:46
missNyza missNyza is offline
Registered User
 
Join Date: Dec 2010
Posts: 2
put the result into list

Hi,
i have a data like below

CASE_ID YEAR
---------- -------
776 2007
776 2008


i want to get the year as a list for example

CASE_ID YEAR
776 2007,2008


can i get it without using stored procedure?
Any help would be most appreciated. Thanks.

Last edited by missNyza; 12-21-10 at 21:52.
Reply With Quote
  #2 (permalink)  
Old 12-22-10, 05:57
Lim Tjie Siong Lim Tjie Siong is offline
Registered User
 
Join Date: Dec 2010
Posts: 3
shell script

I'm not sure in db2. If I were you, I will shell script to do it.
Reply With Quote
  #3 (permalink)  
Old 12-22-10, 06:24
sanjsajjan sanjsajjan is offline
Registered User
 
Join Date: Dec 2010
Posts: 7
U can get output like that using simple query.

select case_id,wm_concat(year)
from table_name
group by case_id


Thanks,
Naganath
Reply With Quote
  #4 (permalink)  
Old 12-22-10, 09:25
dbzTHEdinosaur dbzTHEdinosaur is offline
Registered User
 
Join Date: Jun 2007
Location: germany
Posts: 96
is the oracle function wm_concat, also for db2?
__________________
Dick Brenholtz, Ami in Deutschland
Reply With Quote
  #5 (permalink)  
Old 12-23-10, 01:45
missNyza missNyza is offline
Registered User
 
Join Date: Dec 2010
Posts: 2
i'm using db2. wm_concat will give error SQLSTATE: 56098.
maybe i should use shell script as suggested.

thanks.
Reply With Quote
  #6 (permalink)  
Old 12-28-10, 14:32
JAYANTA_DATTA JAYANTA_DATTA is offline
Registered User
 
Join Date: Oct 2004
Location: DELHI INDIA
Posts: 336
you can refer the db2 sql cookbook and find few examples there to denormalize result set in the output ( there are few for normalizing too). That will give you some direction.
__________________

Jayanta Datta
DB2 UDB DBA
IBM India, Global Delivery
New Delhi
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