Splitting the rows

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
paranoid
Premium Member
Premium Member
Posts: 185
Joined: Tue May 29, 2007 5:50 am

Splitting the rows

Post by paranoid »

Hi,

We have a table where the layout looks as below:

BRANCH JOBNO REGION DISTRIBUTOR SALESMAN1 SALESMANPCT1 SALESMAN2 SALESMANPCT2 SALESMAN3 SALESMANPCT3

We are supposed to fetch the records into a new table with the following layout:

BRANCH JOBNO REGION DISTRIBUTOR SALESMAN SALESMANPCT

We could fetch the records in to the new table using the UNION operator as follows:

SELECT BRANCH,
JOBNUMBER,
DISTRIBUTOR,
SALESMAN1,
SALESMANPCT
FROM SALESMAN1)
UNION
(SELECT BRANCH,
JOBNUMBER,
DISTRIBUTOR,
SALESMAN2,
SALESMANPCT2
FROM SALESMAN2)

UNION
(SELECT BRANCH,
JOBNUMBER,
DISTRIBUTOR,
SALESMAN3,
SALESMANPCT3
FROM SALESMAN3)

But i would like to do the same thing using datastage job as well. Please advise.

Thanks
Sue
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What you seek to do is called a "horizontal pivot" and is performed by the Pivot stage in DataStage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
paranoid
Premium Member
Premium Member
Posts: 185
Joined: Tue May 29, 2007 5:50 am

Post by paranoid »

Ray,

Thank you for your swift response. I am currently running a test job to do this using pivot stage. But i dont find a pdf in my installation directory:
C:\Program Files\Ascential\DataStage7.5\Docs\

I dont have a installation CD also..

Can you help me providing that pdf?

Thanks
Sue
paranoid
Premium Member
Premium Member
Posts: 185
Joined: Tue May 29, 2007 5:50 am

Post by paranoid »

Also, I could see only one Pivot stage in my Processing group in the designer. I am using DS 7.5.1


Thanks

Sue
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There is only one pivot stage in version 7.5.

Search on your client machine for a document called Pivot.pdf - this is the manual.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There is only one Pivot stage and it only does horizontal pivots. There should also be a Help button in the stage which explains how to use the stage.
-craig

"You can never have too many knives" -- Logan Nine Fingers
paranoid
Premium Member
Premium Member
Posts: 185
Joined: Tue May 29, 2007 5:50 am

Post by paranoid »

Chulett,

I tried 'Help' also but it is more of theoretical rather than practical(that provides with an example).

Thanks

Sue
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Do you have a specific question on the stage or need some help getting the output you are after?
-craig

"You can never have too many knives" -- Logan Nine Fingers
paranoid
Premium Member
Premium Member
Posts: 185
Joined: Tue May 29, 2007 5:50 am

Post by paranoid »

Chulett,

I was struggling on using the derivation, but after some tries found it:

Output Columsn SPCT : SPCT1,SPCT2,SPCT3(Derivation Used)

Is there any way to get distinct records in pivot stage itself? Or Do i need to use Sort after pivot?

Please advise.

Sue
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Looks good and any 'Key' columns will be repeated on each row. There is no distinctness to a pivot, you'd need to enforce that downstream.
-craig

"You can never have too many knives" -- Logan Nine Fingers
paranoid
Premium Member
Premium Member
Posts: 185
Joined: Tue May 29, 2007 5:50 am

Post by paranoid »

Thank You So Much Chulett.

Will let you know once i get my desired result.
Post Reply