tsql - Natural order by on period-delimited string in MSSQL server 2005 -
i've been working on producing period-delimited hierarchy of integers performs 'natural' order on select query. i've had go , query below touted solution decimal ordering:
select id tablenm order case isnumeric(id + 'e0') when 1 0 else 1 end, id
however, i'm not technically working decimal in cases have limited success. please note, there may multiple levels in hierarchy - i've shown 3 in example brevity.
the sql above produces following output:
id 1 1.1 5 5.1 5.10 5.2 1.5.1 4.2.1 1.3.1 3.2.1
i need like:
id 1 1.1 1.3.1 1.5.1 3.2.1 4.2.1 5 5.1 5.2 5.10
thanks insight you're able give.
i try following answer https://stackoverflow.com/a/6541020/638400
note can't take credit answer - sql quite exceptional
Comments
Post a Comment