In Oracle, just using the ORDER BY
does not sort version numbers.
My Version_Number
field is declared as a VARCHAR
and I cannot change
This is one way to do it. First order by the number before .
and then by the numbers after .
select version_number
from mytable
order by substr(version_number, 1, instr(version_number,'.')-1) desc
,length(substr(version_number, instr(version_number,'.')+1)) desc
,substr(version_number, instr(version_number,'.')+1) desc