Hi there,
clapag22's solution it interesting.... he/she is stripping of the leading values in the slots column up to (but not including) the hythen. It's quite interesting and neat.
Not sure why it doesn't work...probably some minor typo or syntax error. (By the way, it would have been more helpful, or easier to diagnose, if you had posted the actual error message instead of just "...it gives me an error."
I am wondering if there is an issue when 'slots' does not contain a '-' (if that is possible.) That might cause this solution to fail, I dunno.
Borrowing from clapag22's approach, here's a version that does seem to work well on my system...no syntax error, and seems to sort properly. Try it if you like. Pretty ugluy, though.
--------------------------
order by
left(slots,(case when (charindex('-', slots) - 1) = -1 then 0 else (charindex('-', slots) - 1) end))
---------------------------
And here's a slightly different version. Just as ugly.
order by
Cast(left(slots,(case when (charindex('-', slots) - 1) = -1 then 0 else (charindex('-', slots) - 1) end)) as int)
---------------------------