oracle - sql order by numeric string -


I am using Oracle 10. I need to sort my result set according to two numerical string fields. One type of criterion area keeps such data: FIELD1:

  FO-00001001001 FO-00001002001 FO-00001003001 Class-00001003001 FC-1022001003001  

Other:

  FIELD2: 000203 000567 349990  

I need to combine two criteria, first criteria take precedence, as a result of which the ascending order is required is.

How do I write this SQL?

Since the numbers are null-padded, so you can compare them as strings:

  SELECT ... from ... ORDER field1 ASC, field2 ASC  

or if you want to ignore prefix in field1 : <: >

  SELECT ..., SUBSTR (field 1, 3) from AS stripped_field1 ... order by stripped_field1 ASC, field2 ASC  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -