create table my_ee ( value varchar(100));
insert into my_ee values ('A10');
insert into my_ee values ('B100');
insert into my_ee values ('A2');
insert into my_ee values ('AA1');
insert into my_ee values ('AD200');
insert into my_ee values ('32');
insert into my_ee values ('11');
insert into my_ee values ('A1');
select value
, left(value, patindex('%[0-9]%', value) -1 ) prefix
, cast(substring(value, patindex('%[0-9]%', value) , len(value)) as int) numvalue
from my_ee
order by prefix, numvalue
create table my_ee ( value varchar2(100));
insert into my_ee values ('A10');
insert into my_ee values ('B100');
insert into my_ee values ('A2');
insert into my_ee values ('AA1');
insert into my_ee values ('AD200');
insert into my_ee values ('32');
insert into my_ee values ('11');
insert into my_ee values ('A1');
select value
, regexp_substr(value, '([^0-9]*)') prefix
, to_number(substr(value, nvl( 1+length(regexp_substr(value, '([^0-9]*)')),1),length(value))) numvalue
from my_ee
order by prefix, numvalue;
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)