有人能帮我如何对这个进行排序吗?
我有一个动态模式的列表需要排序,其中包含字母和数字。
CREATE TABLE dbo.Pattern (Pattern varchar(50) NULL)
INSERT INTO dbo.Pattern (Pattern) VALUES ('A11')
INSERT INTO dbo.Pattern (Pattern) VALUES ('A12')
INSERT INTO dbo.Pattern (Pattern) VALUES ('A8')
INSERT INTO dbo.Pattern (Pattern) VALUES ('A2')
INSERT INTO dbo.Pattern (Pattern) VALUES ('B6')
INSERT INTO dbo.Pattern (Pattern) VALUES ('B21')
INSERT INTO dbo.Pattern (Pattern) VALUES ('B10')
INSERT INTO dbo.Pattern (Pattern) VALUES ('B3')
INSERT INTO dbo.Pattern (Pattern) VALUES ('B100')
INSERT INTO dbo.Pattern (Pattern) VALUES ('B2')
INSERT INTO dbo.Pattern (Pattern) VALUES ('AA')
INSERT INTO dbo.Pattern (Pattern) VALUES ('BA')
INSERT INTO dbo.Pattern (Pattern) VALUES ('A20')
INSERT INTO dbo.Pattern (Pattern) VALUES ('AB')
INSERT INTO dbo.Pattern (Pattern) VALUES ('BB')
SELECT Pattern FROM dbo.Pattern ORDER BY Pattern
DROP Table dbo.Pattern
结果如下所示:
A11
A12
A2
A20
A8
AA
AB
B10
B100
B2
B21
B3
B6
BA
BB
但是我想展示的只是像这个结果一样:
AA
A1
A2
A8
A11
A12
A20
AB
BA
B2
B3
B6
B10
B21
B100
BB
AA
会排在B100
之后?在AAA
和BA1
之间,哪个会先出现?为什么?如果你能定义这个逻辑,我相信你很容易就能回答自己的问题了。 - Tab Alleman