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 > With clause

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-06-08, 04:33
usDB2 usDB2 is offline
Registered User
 
Join Date: May 2008
Posts: 39
With clause

Hi

Myreq is:I have emp rable with data as :
100 a
100 b
100 u

it should be displayed as

100 a b c

My qry is :
WITH PARENT (NO, NAME,NAME1,level) as
(SELECT NO, NAME ,NAME,1
FROM IDM_DEV.zz_empt2
WHERE NO =100
UNION ALL
SELECT P.no, C.name,P.name,P.level+1
FROM IDM_DEV.zz_empt2 C
,PARENT P
WHERE P.NO =C.NO
)
SELECT no,name,name1
FROM PARENT where level=2;

I am not getting dsired result..Please suggest any other way to do it
thnaks
Reply With Quote
  #2 (permalink)  
Old 08-06-08, 05:49
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
there have been many similar requests before
search on pivot data or goto developer works and check for pivot table db2
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #3 (permalink)  
Old 08-06-08, 06:13
rahul_s80 rahul_s80 is offline
Registered User
 
Join Date: Jul 2006
Location: Pune , India
Posts: 433
if v9 you can also use xml functions to acheive same
__________________
Rahul Singh
Certified DB2 9 DBA / Application Developer
Reply With Quote
  #4 (permalink)  
Old 08-06-08, 07:14
usDB2 usDB2 is offline
Registered User
 
Join Date: May 2008
Posts: 39
Can you please give some example,if possible
Reply With Quote
  #5 (permalink)  
Old 08-06-08, 09:35
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Reply With Quote
  #6 (permalink)  
Old 08-06-08, 09:42
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Why don't you try to search for it, first?
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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