algotube
asked on
I have a sort order question
The following table has a series of text fields that I need to return in descending order.
Seq Data String
1 2011-01-12-00.00.00.000000
2 2011-01-12-XX.00.00.000000
3 2011-01-12-XX-00.00.999999
4 2011-01-12-00.00.00.999999
How do I find out the sequence that these will be returned in descending order in SQL Server 2005?
This info is needed for comparison sake between IBM mainframe world and Oracle world.
Seq Data String
1 2011-01-12-00.00.00.000000
2 2011-01-12-XX.00.00.000000
3 2011-01-12-XX-00.00.999999
4 2011-01-12-00.00.00.999999
How do I find out the sequence that these will be returned in descending order in SQL Server 2005?
This info is needed for comparison sake between IBM mainframe world and Oracle world.
ASKER
This is what I received when I ran the query in SQL Server
SEQ Data String
1 2011-01-12-00.00.00.000000
2 2011-01-12-XX.00.00.000000
3 2011-01-12-XX-00.00.999999
4 2011-01-12-00.00.00.999999
This is what my buddy received when he ran it in IBM mainframe world
SORTED DESCENDING:
SEQ DATA STRING
4 2011-01-12-00.00.00.999999
1 2011-01-12-00.00.00.000000
3 2011-01-12-XX-00.00.999999
2 2011-01-12-XX.00.00.000000
Why the difference................
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You will have to find a common collation in order to sort the same way.
So for example you could use something like this to change the sort order to match the mainframe:
ORDER BY YourColumn COLLATE SQL_EBCDIC037_CP1_CS_AS
ORDER BY YourColumn COLLATE SQL_EBCDIC037_CP1_CS_AS
ASKER
8080_Diver:
Do you still have the query you used......if you do can you please post.
Thank you so much for your help
Do you still have the query you used......if you do can you please post.
Thank you so much for your help
algotube,
I must confess, I didn't use a query but, rather, just my knowledge of how the results would come out.
However, the query has already been posted (see response #35507991):
In looking at the output you say you got, though, it would appear that you omitted the ORDER BY LTRIM(DataString) DESC line.
I must confess, I didn't use a query but, rather, just my knowledge of how the results would come out.
However, the query has already been posted (see response #35507991):
SELECT SEQ
,LTRIM(DataString)
FROM myTable
ORDER BY LTRIM(DataString) DESC
In looking at the output you say you got, though, it would appear that you omitted the ORDER BY LTRIM(DataString) DESC line.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Guys I can't thank you enough for all your replies, very very much appreciated
select top 100 *
from myTable
ORDER BY DataString DESC