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: 1868
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: 1868
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 Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am

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