where子句中case语句的问题 [英] problems with case statement in where clause

查看:84
本文介绍了where子句中case语句的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人能告诉我这里的代码有什么问题:


SELECT COUNT(*)

FROM CALL

WHERE CALL.DESCRIPTION =

CASE

WHEN @ Param1 =''In''THEN''in''

WHEN @Param1 =''Out''THEN''Out''

END


我收到错误,参数是正确的。


如果有任何混淆,我会接受1个参数,即要么是'In''还是''Out''。根据参数,我想将Call.Description设置为In或Out。


提前感谢!

I was wondering if someone would be able to tell me what is wrong with my code here:

SELECT COUNT(*)
FROM CALL
WHERE CALL.DESCRIPTION =
CASE
WHEN @Param1 = ''In'' THEN ''In''
WHEN @Param1 = ''Out'' THEN ''Out''
END

I am getting an error that parameter is correct.

And just in case there is any confusion, I am taking in 1 parameter that is either going to be ''In'' or ''Out''. Depending on the param, I want to set Call.Description to either ''In'' or ''Out''.

Thanks in advance!

推荐答案


我想知道是否有人能告诉我这里的代码有什么问题:


SELECT COUNT(*)

FROM CALL

WHERE CALL.DESCRIPTION =

CASE

WHEN @ Param1 ='''''''''''''

WHEN @ Param1 =''Out''THEN''Out''

END


我收到一个错误,参数是正确的。


为了防止出现任何混淆,我接受1个参数,要么是' '在''或''出''。根据参数,我想将Call.Description设置为In或Out。


提前致谢!
I was wondering if someone would be able to tell me what is wrong with my code here:

SELECT COUNT(*)
FROM CALL
WHERE CALL.DESCRIPTION =
CASE
WHEN @Param1 = ''In'' THEN ''In''
WHEN @Param1 = ''Out'' THEN ''Out''
END

I am getting an error that parameter is correct.

And just in case there is any confusion, I am taking in 1 parameter that is either going to be ''In'' or ''Out''. Depending on the param, I want to set Call.Description to either ''In'' or ''Out''.

Thanks in advance!



你得到了什么错误?


你实际上可以这样做:

What error are you getting?

You can actually just do this:

展开 | 选择 | Wrap | 行号



你得到什么错误?


你实际上可以这样做:

What error are you getting?

You can actually just do this:

展开 | 选择 | Wrap | 行号


如果我理解正确的话:


如果@param =''在''那么你想要所有行都有CALL.DESCRIPTION = In''。

如果@param =''Out''那么你想要所有的行都有CALL.DESCRIPTION = Out''。

if @param =''Any''那么你想要所有的行,CALL.DESCRIPTION =''In''或CALL.DESCRIPTION =''Out''

如果我的假设是错误的,请不要阅读以下内容,否则请尝试以下操作:

So if I understand it right:

if @param = ''In'' then you want all rows with CALL.DESCRIPTION = In''.
if @param = ''Out'' then you want all rows with CALL.DESCRIPTION = Out''.
if @param = ''Any'' then you want all rows, both CALL.DESCRIPTION = ''In'' or CALL.DESCRIPTION = ''Out''

If my assumption is wrong, don''t read the following, otherwise try the following:

展开 | 选择 | 换行 | 行号


这篇关于where子句中case语句的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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