Page 1 of 1

Column sort

Posted: Mon Jul 27, 2009 3:52 am
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

Posted: Mon Jul 27, 2009 4:07 am
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 ?

Posted: Mon Jul 27, 2009 4:09 am
by sunitha_cts
Yes you are right

Posted: Mon Jul 27, 2009 4:11 am
by sunitha_cts
Hi,

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

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

Posted: Mon Jul 27, 2009 4:15 am
by priyadarshikunal
split both coloums, sort them individually then a vertical pivot -> funnel ->horizontal pivot.

Posted: Mon Jul 27, 2009 4:49 am
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.

Posted: Mon Jul 27, 2009 4:50 am
by nagarjuna
cut -d ',' -f 1 | > f1 -----> sort asc

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

then use paste command .

Posted: Mon Jul 27, 2009 5:14 am
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