Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
DB2 Sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: DB2 Sort
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

Senior Member


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

PostPosted: Thu Sep 20, 2012 11:14 am    Post subject:
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

Site Director


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

PostPosted: Fri Sep 21, 2012 8:16 am    Post subject:
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

Senior Member


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

PostPosted: Fri Sep 21, 2012 12:54 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Extract record for change in combinat... Trinadh DFSORT/ICETOOL 6 Thu Nov 23, 2017 3:32 pm
No new posts JOINKEYS Paired and Unpaired Sort on ... MFwhiz DFSORT/ICETOOL 7 Tue Nov 07, 2017 2:46 am
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts JOINKEYS Paired and Unpaired Sort MFwhiz DFSORT/ICETOOL 4 Fri Sep 29, 2017 1:48 am
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us