select case when col between 0 and 100 then 1 when col between 100 and 200 then 2 end from tb SQL code: select case when '0-100' then 1 else 0 end as'col1', case when '101-200' then 2 else 0 end as 'col2' from tb
SQL code: select case when col between 0 and 100 then 1 when col between 100 and 200 then 2 end from tb
select *,(select count(1) from tb where right(A,len(A) - charindex('-',A))<=right(t1.A,len(t1.A) - charindex('-',t1.A))) from tb t1 join tb t2 on right(t1.A,len(t1.A) - charindex('-',t1.A))+1 = left(t2.A,charindex ('-',t2.A) -1)