Approach required for this Pivoting example.

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
pranay
Participant
Posts: 20
Joined: Mon Jan 09, 2006 3:34 pm

Approach required for this Pivoting example.

Post by pranay »

Hi All,
I need to implement something like this : I have a table that contains empid, monthyear and salary. the primary key is the combination of empid and monthyear. Here's the data in the table
101 Jan 07 5000
101 Feb 07 4850
101 Mar 07 4850
101 Apr 07 4850
101 May 07 4850
101 July 07 4850
102 Feb 07 4850
102 Mar 07 6050
103 Feb 07 4050

for all the distinct rows in monthyear column it should create seperate columns and display the output as given below.
The output should be
Jan07 Feb07 Mar07 Apr07 May07 June07 July07
101 5000 4850 4850 4850 4850 ---- 4850
102 --- 4850 6050 ---- ---- ---- ----
103 ----- 4050 ----- --- ---- ---- ----

Can any one give me the approach for this. Thanks in advance. Pranay
Pranay
Seatte, WA
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

easier to process using rdbms stored procedures.
pranay
Participant
Posts: 20
Joined: Mon Jan 09, 2006 3:34 pm

Post by pranay »

Hi ramesh, Could you please send me the stored proc for the same.
rameshrr3 wrote:easier to process using rdbms stored procedures.
Pranay
Seatte, WA
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:D He wasn't offering to build one for you, just stating his preference as to the approach to take to solve this.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

At DSXchange we dont guarantee that solutions to problems will be given , helpful suggestions and hints are somethings that you can look for, i can however send you a dsx file for a vertical pivot operation that is only slightly different from your case-provided you give me your email id.

Writing a procedure in PL/SQl for your case should be fairly straightforward,more so if you use intermediate tables- however the target file structure is what i would call a sparse format - leaidng to unecessary disk space consumption if left uncompressed. How many columns do you plan to have in the file ? 1 field for every month of every year?
Or 12 month fields for every file and 1 file per year?

alternatively you can sort your input file by month and write to a folder stage with month as output key column, that way you will end up with 1 file for every month, after which you can join fields based on key value and concatenate.

On parallel extender you may need to explore options on your restructure stages.
pranay
Participant
Posts: 20
Joined: Mon Jan 09, 2006 3:34 pm

Post by pranay »

Thanks Ramesh for the valuable suggestions.
you can send the dsx to me at kpranay81@gmail.com.
Also i need to have one output file per year with 12 month fields.
rameshrr3 wrote:At DSXchange we dont guarantee that solutions to problems will be given , helpful suggestions and hints are somethings that you can look for, i can however send you a dsx file for a vertical pivot operation that is only slightly different from your case-provided you give me your email id.

Writing a procedure in PL/SQl for your case should be fairly straightforward,more so if you use intermediate tables- however the target file structure is what i would call a sparse format - leaidng to unecessary disk space consumption if left uncompressed. How many columns do you plan to have in the file ? 1 field for every month of every year?
Or 12 month fields for every file and 1 file per year?

alternatively you can sort your input file by month and write to a folder stage with month as output key column, that way you will end up with 1 file for every month, after which you can join fields based on key value and concatenate.

On parallel extender you may need to explore options on your restructure stages.
Pranay
Seatte, WA
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

This is sounding more and more like a commercial arrangement. If you want Ramesh (or anyone else) to work for you how much are you prepared to pay for it?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

Hi ramesh, Could you please send me the stored proc for the same.
:lol: , well no commercial engagements yet ..i could also post the 'dsx' or job report on dsxchange if there was place to upload it.
Post Reply