I have it
declare @testtable table (test nvarchar(max)) insert into @testtable (test) values ('1.2.3') insert into @testtable (test) values ('1.20.3') insert into @testtable (test) values ('1.19.x') insert into @testtable (test) values ('1.x.x') insert into @testtable (test) values ('1.19.3') insert into @testtable (test) values ('DEC09') insert into @testtable (test) values ('Plutonium') insert into @testtable (test) values ('dec09') insert into @testtable (test) values ('N/A') insert into @testtable (test) values ('MyTest20') insert into @testtable (test) values ('20MyTest') insert into @testtable (test) values ('1.4.18') insert into @testtable (test) values ('1.4.168') select * from @testtable order by test asc;
which outputs
1.19.3 1.19.x 1.2.3 1.20.3 1.4.168 1.4.18 1.xx 20MyTest DEC09 dec09 MyTest20 N/A Plutonium
but I would like the output order to be
1.2.3 1.4.18 1.4.168 1.19.3 1.19.x 1.20.3 1.xx 20MyTest DEC09 dec09 MyTest20 Plutonium N/A
(note that N / A is โmagicโ and always the largest, โversionโ (ex 1.2.3) always has 3 digits, although one or more digits can be char x to indicate โany digitโ that should always be considered the largest possible number)
How to do this in SQL Server?
source share