我正在开发一个应用程序,成员可以选择DVD并将其添加到“愿望清单”中。可以使用当前愿望清单打印报告。如果DVD标题包含序号(第一,第二,第三,第四等),我的客户希望按数字(1,2,3,4等)排序。
例如,如果此脚本用于创建,填充和查询表:
CREATE TABLE Dvd (
TitleID INT IDENTITY PRIMARY KEY
,Title VARCHAR(256)
)
GO
INSERT INTO Dvd (Title) VALUES ('M*A*S*H - The Complete First Season')
INSERT INTO Dvd (Title) VALUES ('M*A*S*H - The Complete Second Season')
INSERT INTO Dvd (Title) VALUES ('M*A*S*H - The Complete Third Season')
INSERT INTO Dvd (Title) VALUES ('M*A*S*H - The Complete Fourth Season')
SELECT Title FROM Dvd ORDER BY Title
查询返回以下结果:
M*A*S*H - The Complete First Season M*A*S*H - The Complete Fourth Season M*A*S*H - The Complete Second Season M*A*S*H - The Complete Third Season
是否有任何建议有效地对标题进行排序,以便根据与序数文本相关联的实际数字按顺序列出标题:
M*A*S*H - The Complete First Season M*A*S*H - The Complete Second Season M*A*S*H - The Complete Third Season M*A*S*H - The Complete Fourth Season
答案 0 :(得分:1)
假设TitleID按顺序增加,只需按TitleID排序。