g_currier
asked on
Include column header in pivoted result
Hi,
I do not consider myself a novice but once in a while, a problem comes along that may be simple to someone else but for me is incomprehensible.
I hope someone can help shed some light on this.
I would like to include the column header in the result of a query.
If you have ever used PL/SQL developer from AllroundAutomations you will know what I am talking about when I say I want my result to look like the pivoted record view. Â I have tried to figure out how this done by digging into the program itself but I could not find how to do it in SQL or PL/SQL (though I am sure there is a way)
Here is what I want to do:
Can someone help? Â I have been at this for 2 days now and am no closer to a solution.
The reason I need this is so that I can join the column header value to another table and include the values of each based on the header. Â The result set would be fed into another table and loaded into a migration tool. Â I would just change the structure of the tables to do this more easily, but that is not an option available to me.
I appreciate any advice or help.
Thanks
I do not consider myself a novice but once in a while, a problem comes along that may be simple to someone else but for me is incomprehensible.
I hope someone can help shed some light on this.
I would like to include the column header in the result of a query.
If you have ever used PL/SQL developer from AllroundAutomations you will know what I am talking about when I say I want my result to look like the pivoted record view. Â I have tried to figure out how this done by digging into the program itself but I could not find how to do it in SQL or PL/SQL (though I am sure there is a way)
Here is what I want to do:
take this format:
table 1
COLUMN_A COLUMN_B COLUMN_C COLUMN_D
---------- ---------- ---------- ----------
Val_A1 Val_B1 Val_C1 Val_D1
Val_A2 Val_B2 Val_C2 Val_D2
and transform it to this:
table 2
COLUMN_NAME COLUMN_VALUES
----------- -------------
COLUMN_A Val_A1
COLUMN_B Val_B1
COLUMN_C Val_C1
COLUMN_D Val_D1
Can someone help? Â I have been at this for 2 days now and am no closer to a solution.
The reason I need this is so that I can join the column header value to another table and include the values of each based on the header. Â The result set would be fed into another table and loaded into a migration tool. Â I would just change the structure of the tables to do this more easily, but that is not an option available to me.
I appreciate any advice or help.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The query (modified to fit my data) and the output:
Open in new window
Appreciate the link!