where 子句中的 case 语句使用 not like 和 is not null

SgtOVERKILL

我正在使用存储过程从现有表中提取数据,该存储过程具有用户通过复选框在前端选择的一些是或否选项。我想限制If为他们做出的每个选择写一堆不同的陈述。

我的 where 子句的这一部分有效。数据是YN用于此列。

Where... and IsSigned = Case When @IncludeSigned = 'Y' then IsSigned else 'N' end

我想添加到 where usingis not null以及not like是否可以在方括号之间添加到目前为止我有

and SignatureType = case when @IncludeElectronic = 'Y' then Type else [NOT like electronic] end

and ReviewDate = Case When @HasReviewDate = 'Y' then [ReviewDate is not null] else null end

安森·阿里卡特

这可能会帮助您使用 AND/OR 而不是 case

where (ReviewDate is not null or @HasReviewDate = 'Y' ) And (....)

即当@HasReviewDate = 'Y' 查询将返回ReviewDate 不为空的记录,当@HasReviewDate != 'Y' 时查询将返回ReviewDate 为空的记录

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章