Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Order by char() field

epipkoMay 25 2020 — edited May 25 2020

Oracle 9.2.0.8 on Windows. I know, I know ... we're in the process of upgrading to 19c

Size_id is defined as CHAR(5) in the table

I have the following query that returns a list of sizes that needs to be sorted "the right way". I can use decode/case to sort S,M,L,XL but is there a way to do it for numbers and chars in one statement?

select size_id

from oh_supply

where color_id = vColor_id

order by size_id

Depending on the vColor_id, this query returns these results:

0   

1   

11  

13  

3   

5   

7   

9   

OR

L   

M   

S   

XL  

The expected result is

0   

1      

3

5    

7   

9

11

13

OR

S

M

L

XL

Comments
Post Details
Added on May 25 2020
2 comments
294 views