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)
ͨ¹ýNAME×Ö¶ÎÌõ¼þ²éѯһ¸öÊý¾Ý±í£¬¼ÙÉèÎÒÓÐ100¸öÐÕÃû£¬ÓÐÒÔÏÂÁ½¸ö·½·¨£¬ ·½·¨1£º °Ñ100¸öName ×é³ÉÒ»¸öSQLÓï¾ä£¬±ÈÈç Select * from tmp_table where Name='ÕÅÈý' or Name ='ÀîËÄ' Or ...Or Name='µÚÒ»°Ù¸öÐÕÃû' ......