动态 Where 子句 T-SQL 变量运算符

Dynamic Where Clause T-SQL varibable operator

我正在尝试根据存储过程的输入变量在 sql 中设置我的 where 条件。

Where RF.InternalCompany = @Company  
And RF.Installdate between @Datefrom  and @DateTo
AND CASE WHEN @ContractType = 'Single Asset Contract' THEN numA.NumOfAssets = 1 
    WHEN @ContractType = 'Multi-Asset Contract' THEN numA.NumOfAssets > 1
    END

如何设置?

像下面这样更改..

Where RF.InternalCompany = @Company  
And RF.Installdate between @Datefrom  and @DateTo
AND ((@ContractType = 'Single Asset Contract' AND     numA.NumOfAssets = 1 ) Or 
(@ContractType = 'Multi-Asset Contract' AND numA.NumOfAssets > 1))
AND 
(
    ( @ContractType = 'Single Asset Contract' AND numA.NumOfAssets = 1 )
    OR 
    ( @ContractType = 'Multi-Asset Contract'  AND numA.NumOfAssets > 1 )
)