create table versions
(
version varchar2(30)
);
insert into versions values ('1.1');
insert into versions values ('1.1.1');
insert into versions values ('1.2.10');
insert into versions values ('1');
insert into versions values ('1.10.1');
insert into versions values ('1.1.2');
insert into versions values ('2.1');
insert into versions values ('2');
insert into versions values ('1.10.2');
insert into versions values ('1.2');
insert into versions values ('1.2.4');
insert into versions values ('1.2.5');
select * from versions;
SELECT version
FROM versions
ORDER BY TO_NUMBER (REGEXP_SUBSTR (version, '\d+')),
TO_NUMBER (REGEXP_SUBSTR (version,'\d+',1,2)) NULLS FIRST,
TO_NUMBER (REGEXP_SUBSTR (version,'\d+',1,3)) NULLS FIRST;
SELECT version
FROM versions
order by to_number(regexp_substr(version, '[[:digit:]]+', 1, 1)) nulls first,
to_number(regexp_substr(version, '[[:digit:]]+', 1, 2)) nulls first,
to_number(regexp_substr(version, '[[:digit:]]+', 1, 3)) nulls first;
I hope you all have enjoyed reading this article. Comments are welcome....
(
version varchar2(30)
);
insert into versions values ('1.1');
insert into versions values ('1.1.1');
insert into versions values ('1.2.10');
insert into versions values ('1');
insert into versions values ('1.10.1');
insert into versions values ('1.1.2');
insert into versions values ('2.1');
insert into versions values ('2');
insert into versions values ('1.10.2');
insert into versions values ('1.2');
insert into versions values ('1.2.4');
insert into versions values ('1.2.5');
select * from versions;
SELECT version
FROM versions
ORDER BY TO_NUMBER (REGEXP_SUBSTR (version, '\d+')),
TO_NUMBER (REGEXP_SUBSTR (version,'\d+',1,2)) NULLS FIRST,
TO_NUMBER (REGEXP_SUBSTR (version,'\d+',1,3)) NULLS FIRST;
SELECT version
FROM versions
order by to_number(regexp_substr(version, '[[:digit:]]+', 1, 1)) nulls first,
to_number(regexp_substr(version, '[[:digit:]]+', 1, 2)) nulls first,
to_number(regexp_substr(version, '[[:digit:]]+', 1, 3)) nulls first;
I hope you all have enjoyed reading this article. Comments are welcome....
No comments:
Post a Comment