SQL - Sortieren nach mit alphanumerischen Zeichen
Ich habe folgende Tabelle:
create table #tbl
(
product_id nvarchar(50)
)
insert into #tbl values ('011014-A11')
insert into #tbl values ('011014-A10')
insert into #tbl values ('011014')
insert into #tbl values ('011014-A1')
insert into #tbl values ('011014-A2')
Ich möchte die Produkt-IDs wie folgt bestellen (vom kleinsten zum größten):
011014
011014-A1
011014-A2
011014-A10
011014-A11
Das habe ich versucht, aber es funktioniert nicht:
select product_id
from #tbl
order by product_id desc
Wie mache ich das?
Und wie bekomme ich nur die beste product_id? Ich habe es versucht, aber es hat nicht funktioniert:
select top 1 product_id
from #tbl
order by product_id desc