As dalvait request if the condition in case right?

(SELECT c.ClassifierGroupId FROM ClassifierGroup c WHERE c.ClassifierId=
 (CASE WHEN @SupplierContractTypeClassifierGroupid = 0 THEN
(2)
ELSE
(159)
END)
 )


how can I add
AND c.ClassifierGroupId = @SupplierContractTypeClassifierGroupid
if c.ClassifierId = 2
March 19th 20 at 08:51
1 answer
March 19th 20 at 08:53
Solution
SELECT ClassifierGroupId 
 FROM ClassifierGroup 
 WHERE 
 (CASE WHEN @SupplierContractTypeClassifierGroupid = 0 THEN
 IIF((ClassifierId=2) AND (ClassifierGroupId = @SupplierContractTypeClassifierGroupid), 1, 0)
ELSE
 IIF(ClassifierId=159, 1, 0)
 END) = 1

Find more questions by tags SQL Server