c# - How to order a Buildingnumber chronological in MS SQL? -
hello need order list of building in chronological order. here example
select building adress order building asc
result:
emil g1 g10 g2 g3 g4 g5
what need order:
emil g1 g2 g3 g4 g5 g10
is possible? or should create prioritylist can order priority?
i suppose have letter before number.
in way order before letter (a, b, c... g , on) , after number of building.
try this:
select building address order substring(building, 1, 1), convert(int, substring(building, 2, 100))
edit
you can utilize patindex
function regular look (as adviced here)
select building address order substring(building, 1, patindex('%[0-9]%', building) - 1), convert(int, substring(building, patindex('%[0-9]%', building), 100))
c# sql sql-server visual-studio
No comments:
Post a Comment