• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Oracle SQL Order by solution

 
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following column values that I need to have sorted but not by the default sort order. If anyone has any ideas that would be greatly appreciated.

Column values:

TEST_1
TEST_2
TEST_3
TEST_4
TEST_11
TEST_5

By default order by does this

TEST_1
TEST_11
TEST_2
TEST_3
TEST_4
TEST_5

I need this

TEST_1
TEST_2
TEST_3
TEST_4
TEST_5
TEST_11
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you can substring starting just past the "_" then convert the String to an int and then you will get what you are looking for

so something like, but I don't remember the exact syntax

to_number(substr(field,CHAR_AT(field,'_')+1))

So it find where the "_" is then gets the rest of the string past that number, so then you are left with just the number part. Then you convert that to a number and that equation would be in your order by.

Mark
 
Create symphonies in seed and soil. For this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic