select 用户名, 等级=case when score between 10 and 19 then '初级' when score between 20 and 30 then '中级' end from 表
declare @t table([name] varchar(10),jifen int) insert into @t select 'song',10 insert into @t select 'yhtt',11 insert into @t select 'yhy',23 insert into @t select 'yrrr',30 insert into @t select 'ntr',8 insert into @t select 'j',6 select [name],case when jifen>=10 and jifen<20 then '低级' when jifen>=20 and jifen<30 then '中级' end as 等级 from @t
declare @t table([name] varchar(10),jifen int) insert into @t select 'song',10 insert into @t select 'yhtt',11 insert into @t select 'yhy',23 insert into @t select 'yrrr',30select [name],case when jifen>=10 and jifen<=20 then '低级' when jifen>21 and jifen<=30 then '中级' end as 等级 from @t
SELECT NAME, ( CASE WHEN USER_SCORE BETWEEN 10 AND 19 THEN '初级' WHEN USER_SCORE BETWEEN 20 AND 30 THEN '中级' END ) AS 等级 FROM TABLE WHERE 1 = 1
select _name from where _need=( select max(_need) from where (select u_point from users where u_id=?)>=_need这是我自己写的,好象太麻烦了 其中_name是等级名称,_need是达到这个等级所需的分数.u_point是用户现在的分数 大家好象都是用between写的,如果等级有很多的话,我不可能把每一个档次都列出来啊,那句子也太长了! 也许是我没说清楚吧,呵呵! 谁能帮我精简一下我这个句子啊,我这个方法没什么效率可言的
select 用户,等级=(case 积分 when between 10 and 20 then '初级' when between 20 and 30 then '中级' end) from #t
等级=case when score between 10 and 19 then '初级' when score between 20 and 30 then '中级' end
from 表
insert into @t select 'song',10
insert into @t select 'yhtt',11
insert into @t select 'yhy',23
insert into @t select 'yrrr',30
insert into @t select 'ntr',8
insert into @t select 'j',6
select [name],case when jifen>=10 and jifen<20 then '低级'
when jifen>=20 and jifen<30 then '中级'
end as 等级
from @t
insert into @t select 'song',10
insert into @t select 'yhtt',11
insert into @t select 'yhy',23
insert into @t select 'yrrr',30select [name],case when jifen>=10 and jifen<=20 then '低级'
when jifen>21 and jifen<=30 then '中级'
end as 等级
from @t
NAME,
(
CASE
WHEN USER_SCORE BETWEEN 10 AND 19 THEN '初级'
WHEN USER_SCORE BETWEEN 20 AND 30 THEN '中级'
END
) AS 等级
FROM
TABLE
WHERE 1 = 1
from
where _need=(
select max(_need)
from
where (select u_point from users where u_id=?)>=_need这是我自己写的,好象太麻烦了
其中_name是等级名称,_need是达到这个等级所需的分数.u_point是用户现在的分数
大家好象都是用between写的,如果等级有很多的话,我不可能把每一个档次都列出来啊,那句子也太长了!
也许是我没说清楚吧,呵呵!
谁能帮我精简一下我这个句子啊,我这个方法没什么效率可言的
from #t
aniude(重返荣耀) 你用的还是between啊