案例查询需要帮助 [英] Case Query need help

查看:56
本文介绍了案例查询需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

select @return=
case @per
when @per>80 then 5
when @per>60 then 4
when @per>40 then 3
when @per>20 then 1
else 0
end







这个条件的正确查询是什么?

这对我来说不起作用。帮助.....






what is the correct query for this condition?
this is not working for me.plz help.....

now this query returns this error:
Msg 102, Level 15, State 1, Procedure Findpoints, Line 10
Incorrect syntax near '>'.
Msg 102, Level 15, State 1, Procedure Findpoints, Line 18
Incorrect syntax near 'end'.

推荐答案





试试这个...

Hi,

Try this...
select @return= (case 
when @per>80 then 5
when @per <=80 AND @per>60 then 4
when @per <=60 AND @per>40 then 3
when @per <=40 AND @per>20 then 1
else 0
end)



问候,

GVPrabu


Regards,
GVPrabu


declare @return int
declare @per int


set @per=25

select @return=(
case
when @per>80 then 5
when @per>60 then 4
when @per>40 then 3
when @per>20 then 1
else 0
end)

select @return










result
-----------
1

(1 row(s) affected)


这篇关于案例查询需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆