Column sort

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
sunitha_cts
Participant
Posts: 98
Joined: Thu Feb 05, 2009 1:14 am
Location: visakhapatnam
Contact:

Column sort

Post by sunitha_cts »

HI,

I want col1 to be in Asc and col 2 to be in Desc in table of 10 reords.how can i implement this ....by using sort stage we could do for the whole table,but how could we do .....

Thanks
sunitha
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

If you have 10 rows as
1 1
2 2
...
10 10

do you want it as
1 10
2 9
3 8
....
10 1

Is this assumption correct ?
sunitha_cts
Participant
Posts: 98
Joined: Thu Feb 05, 2009 1:14 am
Location: visakhapatnam
Contact:

Post by sunitha_cts »

Yes you are right
sunitha_cts
Participant
Posts: 98
Joined: Thu Feb 05, 2009 1:14 am
Location: visakhapatnam
Contact:

Post by sunitha_cts »

Hi,

col1 7 ,6,3
col2 21,4,9

finally
col1 3,6,7
col2 21,9,4
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

split both coloums, sort them individually then a vertical pivot -> funnel ->horizontal pivot.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Wonder whether the final result will make any sense !!??

But one possible solution can be

Source to be split into 2 sorts and add rownum in transformer followed by join by rownum.

What will be the volume? If it is a small source file, you may be better off doing in Unix itself.
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post by nagarjuna »

cut -d ',' -f 1 | > f1 -----> sort asc

cut -d ',' -f 2 > f2 ----> sort desc

then use paste command .
Nag
sunitha_cts
Participant
Posts: 98
Joined: Thu Feb 05, 2009 1:14 am
Location: visakhapatnam
Contact:

Post by sunitha_cts »

HI,

It is a scenario asked during an intervew that's the reason i posted it,even i felt it makes nosense but i wanted to know if this is possible that's why i posted it .

Thanks one and all who took patience to answer this
Post Reply