Question : sort varchar

column1 is varchar
its values are

xx.x
(15.3)
or
x.x
(6.1)

want to sort by column1 desc

Answer : sort varchar

so something like this
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
select * from yourtable
order by
	cast(parsename(column1 + case len(column1) - len(replace(column1, '.','')) 
				 when 1 then '.0.0'
				 when 0 then '.0.0.0'
				 end
			, 4) as int),

	cast(parsename(column1 + case len(column1) - len(replace(column1, '.','')) 
				 when 1 then '.0.0'
				 when 0 then '.0.0.0'
				 end
			, 3) as int)
Random Solutions  
 
programming4us programming4us