我一直在用这个敲打我的脑袋。
...基本上
where....
and PaymentType IN CASE WHEN @PmtType = 'B' THEN ('BizPay','PerPay')
WHEN @PmtType = 'Z' THEN ('BizPay')
WHEN @PmtType = 'P' THEN ('PerPay')
ELSE NULL END
是我之后的事。我已经尝试重新安排CASE,将它放在括号中,在这里和谷歌,我只是没有让它工作。任何帮助都非常适合。未来的感谢。
答案 0 :(得分:0)
你可以这样使用
and PaymentType =CASE WHEN @PmtType = 'B' THEN
CASE WHEN PaymentType IN ('BizPay','PerPay') THEN PaymentType ELSE '-1' END
WHEN @PmtType = 'Z' THEN
CASE WHEN PaymentType IN ('BizPay') THEN PaymentType ELSE '-1' END
WHEN @PmtType = 'P' THEN
CASE WHEN PaymentType IN ('PerPay') THEN PaymentType ELSE '-1' END
ELSE NULL END
答案 1 :(得分:0)
AND (@PmtType = 'B' and PaymentType in ('BizPay','PerPay'))
or (@PmtType = 'Z' and PaymentType in ('BizPay'))
or (@PmtType = 'P' and PaymentType in ('PerPay'))