using sql to arrange a column with numbers and not letters -


how write sql statement arrange column

columna ------- 10a 11c 12v 10d 8f 8r 9c 

so returns resultset in order

columna ------- 8f 8r 9c 10a 10d 11c 12v 

(in numerical alphabetical order)?

i have tried statement:

select columna tblstudents order columna 

but hasn't worked.

you have split strings numerical part , textual part, , convert numerical part actual number.

i don't know dialect of sql using; microsoft sql server:

select columna tblstudents order   convert(int, substring(columna, 1, patindex('%[^0-9]%') - 1)),   substring(columna, patindex('%[^0-9]%'), 1000) 

the patindex('%[^0-9]%') find first non-digit in string, first substring gets characters that point, , second substring gets characters point end of string.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -