Unanswered: Sorting strings and numbers in SQL quiery
I have a problem with sorting by a string-column when i use SQL quiery on SQLServer. There are both numbers, strings and mixture of both in this column and when i sort it it looks very bad. F.ex. 100 6 600 84 9FT RUBB. I would like to sort numbers numerically and both strings and mixed alphabetically, 6 84 100 600 9FT RUBB. Do you know if this is possible??
Originally posted by margrea
Thanks Markus for your reply
What is "'0000000000'+rtrim(field)" supposed to do? I still get the same alphabetical order on the numbers (i.e. 100 6 600 ...)
this will build up a string for the numbers with leading zeros, so they will get sorted correctly ( pls replace the "field" with your mixed char/numeric column). you might need more zero when your column holds longer strings...