Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 1278
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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us