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: 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 SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm
No new posts Db2 load job abending in SORT mistah kurtz DB2 4 Mon Jun 05, 2017 3:58 pm


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