Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
DB2 query Using Recursion, Converting Rows to Column

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
smilewithashu2

New User


Joined: 28 Dec 2016
Posts: 1
Location: India

PostPosted: Tue Jan 03, 2017 12:50 pm    Post subject: DB2 query Using Recursion, Converting Rows to Column
Reply with quote

I am looking for the query in which I need to convert rows to columns using Db2 recursion:


Input and Output is the attached, I am not looking for the query using CASE as in which case the columns has many values.


Any replies will be appreciated.

Thanks
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1925
Location: UK

PostPosted: Tue Jan 03, 2017 4:19 pm    Post subject:
Reply with quote

Please do not use attachments - a simple cut and paste (using the code tags) is sufficient and more efficient.

There is the same topic just a few below yours. was that not sufficient for you?

And there appears to be a sudden 'requirement' for this type of processing due to a competition. as it is a compettion then getting the answer from a forum is cheating. However, you should research CTEs (Common Table Expressions).
Back to top
View user's profile Send private message
Delip

New User


Joined: 13 Sep 2007
Posts: 46
Location: Bangalore

PostPosted: Wed Feb 15, 2017 12:37 pm    Post subject:
Reply with quote

Hi,

Can't we use Union all like below,

(select HR NAME, 'HR' DEPARTMENT FROM TABLE WHERE HR > ' ')

UNION
(select FINANCE NAME, 'FINANCE' DEPARTMENT FROM TABLE WHERE FINANCE > ' ')

UNION
.
.
.

Regards,
Dileep
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1925
Location: UK

PostPosted: Wed Feb 15, 2017 1:31 pm    Post subject:
Reply with quote

Quote:
Can't we use Union all like below

possibly; but the requirement, for the competition, is to use recursion.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to query MAXGENS of an existing P... Chuchulo Hatyzak JCL & VSAM 0 Wed Nov 22, 2017 10:23 pm
No new posts Native SQL Query kishpra DB2 1 Wed Nov 22, 2017 8:38 pm
No new posts Query on IEFBR14 with GDG Ashishpanpaliya JCL & VSAM 3 Tue Nov 07, 2017 8:34 pm
No new posts Query on XMITIP abdulrafi All Other Mainframe Topics 1 Wed Oct 25, 2017 6:54 pm
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us