hi

(on Z/OS  platform)   can anyone help with an issue  I'm having  with order by  ..   

ordering   on a field with values  ,'1','F','G'   by default returns rows in the order   

F

G

1        

I can do  'order by ... desc'   and  it returns 

1

G

F     

But what will tell DB2 to change the order to sort letters before  numbers  so that   I can get 

1    

F

G

thanks for any  suggestions  

Views: 24

Reply to This

Replies to This Discussion

This is a perfect place to use CAST:

ORDER BY CAST(COL1 AS CHAR(1) CCSID UNICODE)

Assuming COL1 is your column name of course!

Roy,  thank you very much for your reply      this works well  !  

Hello, 

You can add a field with in your select    

 myfield from tab1 order by  case when substr(myfield,1 , 1) between 0 to 9 then 'A' else 'B' end, myfield 

regrds 

Alain 

RSS

Bringing Db2 enthusiasts together virtually. Expert or novice, distributed or mainframe, this is the place for everything DB2.

Forum

5 Ways to Manage Stressful Situations

Started by ashley gill in What's hot ? May 10. 0 Replies

Stress is a common feeling that every human being experiences. As we all know from experience, stress can impact our life negatively and it should, therefore, be dealt with properly. Stress may be unavoidable but how it is handled is our choice.…Continue

Tags: training, corporate

Conversion of BLOB to String/ Text

Started by Jitesh Audichya in Application Development and DB2. Last reply by Jitesh Audichya Apr 24. 2 Replies

Hi All,Problem Statement:I have a field with BLOB data type in DB2 database, I want to extract this blob and convert it to Text. The text data after the conversion will be in Japanese characters. How can I write a select with the conversion from…Continue

Tags: on, DB2, conversion, text, to

© 2020   Created by Surekha Parekh.   Powered by

Badges  |  Report an Issue  |  Terms of Service