Derive Column names from Rows
Posted: Wed Feb 11, 2015 4:47 pm
Hello,
Below is the scenario:
In the data that I am getting from the source Column names are embedded into rows I have to pivot these rows and derive column names from them. I have done the pivoting part which is shown in the sample below, I am left with the challenge to derive column names from rows:
Example:
In the above example 'ABC', 'DEF', 'XYZ' are the names of the columns. I am using 3 columns as example but there can be more than 100 columns one day, next day may be 10 columns etc... so they are dynamic.
Also to add to this ---> Above sample data is for once instance. If there are more than one instance the data will look like below:
Output intended:
The column names are not fixed they vary dynamically.
Please advise.
Any help is appreciated.
Thanks
Below is the scenario:
In the data that I am getting from the source Column names are embedded into rows I have to pivot these rows and derive column names from them. I have done the pivoting part which is shown in the sample below, I am left with the challenge to derive column names from rows:
Example:
Code: Select all
Column1 Column2 Column 3
ABC DEF XYZ
123 234 345
Also to add to this ---> Above sample data is for once instance. If there are more than one instance the data will look like below:
Code: Select all
Column1 Column2 Column 3
ABC DEF XYZ
123 234 345
GHI JKL MNO
333 222 666
ABC MNO
789 555
Output intended:
Code: Select all
ABC DEF XYZ GHI JKL MNO
123 234 345 333 222 666
789 NULL NULL NULL NULL 555
The column names are not fixed they vary dynamically.
Please advise.
Any help is appreciated.
Thanks