IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DB2 Sort


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sumeendar

New User


Joined: 31 Jan 2006
Posts: 39

PostPosted: Thu Sep 20, 2012 10:52 am
Reply with quote

Hi All,

When we try to sort (DB2 SQL query) an alphamueric field which contains numeric and alphabets as values using ORDER BY clause (ascending order), does numeric values comes first OR Alphabets come first, after the sort....

Let me know

Thanks in advance
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Sep 20, 2012 11:14 am
Reply with quote

Well, why don't try it out?

If a column COL1 'has these values':
Code:
1001
1002
AA9999
AB8965

when ORDER by COL1 is performed, the output should be:
Code:
AB8965
AA9999
1001
1002
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Sep 21, 2012 8:16 am
Reply with quote

Hello,

The sequence of the ORDERed data depends on the collating sequence being used.

One of the more frustrating things learned is that these values sort differently in different environments - and it is Not wrong. . . It is usually, however, not what one wants.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Fri Sep 21, 2012 12:54 pm
Reply with quote

That's a valid point Dick. However, unless stated I'll assume it's about DB2 for zOS and the benefit of doubt goes to the batsman! (Okay, a phrase from a cricket-playing-country)
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Fri Sep 21, 2012 1:39 pm
Reply with quote

DB2 for z/OS used to be (almost) EBCDIC only : A-Z0-9
but since DB2 V8 UNICODE is catching up : 0-9A-Z

So actually it is not only different environment, but even different tables order differently.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top