View previous topic :: View next topic
|
Author |
Message |
smilewithashu2
New User
Joined: 28 Dec 2016 Posts: 1 Location: India
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
Delip
New User
Joined: 13 Sep 2007 Posts: 46 Location: Bangalore
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Quote: |
Can't we use Union all like below |
possibly; but the requirement, for the competition, is to use recursion. |
|
Back to top |
|
|
|