I am creating a job to convert a single row into multiple rows so I am using the pivot stage. My input looks like this:
Key Col1 Col2 Col3
A 1 2 3
B 4 5 6
My desired results are:
Key Col Value
A Col1 1
A Col2 2
A Col3 3
B Col1 4
B Col2 5
B Col3 6
I am able to do the horizontal split but how can I populate the 'Col' value in my results so that I can keep track of what my value represents?
Using the Pivot Stage
Moderators: chulett, rschirm, roy
Or if you start from a database table do it in the database:
This will beat Datastage in speed anytime* .
Ogmios
* for between 0 and about 1.000.000 rows depending on the kind of database :D
Code: Select all
SELECT KEY, 'Col1' AS COL, COL1
FROM TABLE
UNION
SELECT KEY, 'Col2' AS COL, COL2
FROM TABLE
UNION
SELECT KEY, 'Col3' AS COL, COL3
FROM TABLE
ORDER BY KEY, COL
Ogmios
* for between 0 and about 1.000.000 rows depending on the kind of database :D