Best practice for sort.

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
sylvan_rydes
Participant
Posts: 47
Joined: Wed Apr 12, 2006 12:13 pm

Best practice for sort.

Post by sylvan_rydes »

Hi All,

This is for knowledge and work support as well. I have two columns and I need to sort with respect to both. But the first column has priority so the second one gets sorted based on first one.

It would be great if someone could explain in detail. Thanks in advance.

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

Post by chulett »

Not sure exactly what you are fishing for here. To sort in any tool based on two columns where one has 'priority' as you've called it, just mention them in the proper order:

Code: Select all

ORDER BY COL1, COL2
The sort stage does something similar using the Sort Specifications property: ColumnName, SortOrder

Code: Select all

COL1 ASC, COL2 asc
There, an upper case SortOrder is a case insensitive sort while a lower case SortOrder is a case sensitive sort.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sylvan_rydes
Participant
Posts: 47
Joined: Wed Apr 12, 2006 12:13 pm

Post by sylvan_rydes »

Hi Craig,

Thanks a lot for helping me out again. I have tried the same thing but din know how to get priority thing done. But now I understand that it is just upper and lower case.

Thanks again.

Sylvan
sylvan rydes
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi Sylvan ,
May I know what you mean 'priority thing'?
Do you mean if a field A and B need to be sorted,
A B
1 1
1 2
1 5
2 7
2 8
2 8
2 9
Is this the order you are expeting? If so it is by default done by the DS.
If you are expecting anything else, pls specify.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yah, the priority part is still a little confused. I'm assuming you just mean that for each value of COL1 you want all values of COL2 in order. And that is just achieved by declaring them in the proper order, from highest to lowest priority to use your terms.

The upper and lower-case SortOrder qualifiers in the Sort stage just tell it how to handle case when sorting... does an upper-case letter sort at the same 'priority' as a lower case letter (meaning the same letters with different case have the same weight) or are they treated differently.

Take for example the following values for COL1: c, e, A, B, D, f, G:

Code: Select all

Case sensitive (COL1 asc): A,B,D,G,c,e,f
Case insensitive (COL1 ASC): A, B, c, D, e, f, G
It's been a long day and I really hope I don't have that bass-ackwards. And that hopefully that helps. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply