(case when @InAct = 1 then (pck.packageID = (select pa.packageID from PakacgeTb pa where (pck.packageID = pa.packageID)
and
((cast(pck.expirydate as date) > cast(getdate() as date)) and cast(pck.BalanceVisit as decimal) > cast(0.00 as decimal)))))
我正在尝试使用where case情况我不知道如何使用它。整个代码在where条件之后使用。
答案 0 :(得分:0)
您可以使用conv = concat . f
where f [] = []
f (x:xs) = map (x+) xs : f xs
> conv [3,10,5]
[13,8,15]
> conv [2,5,15,34]
[7,17,36,20,39,49]
子句中的复合条件转换CASE
表达式,如
WHERE
答案 1 :(得分:0)
Case的简单结构
select
CASE when ISNULL(pa.[packageID],1) = 1 then 'do something'
else 'do something'
end
from PakacgeTb pa
您必须使用然后作为时条件。见下文。
and (CASE when coalesce(@InAct,1) = 1 and pck.packageID in (select
pa.packageID from PakacgeTb pa) and ((cast(pck.expirydate as date) >
cast(getdate() as date)) and cast(pck.BalanceVisit as decimal) > cast(0.00
as decimal))
then 'do something'
else 'this will only execute if when condition does not satisfy'
end