Incorrect Syntax Near `=` - SQL Expression I'm trying to include a conditional check in a WHERE statement.But i keep getting Invalid expression at = 3
WHERE APCCL.data = @coolval
          AND CCMF.Status_ID = 1
          AND APCCL.Status_ID = 1
          AND CLM.myval = 3
          AND 
          CASE APEL.numval
          WHEN 1 THEN  CLM.value =  3 END

Basically i want to check CLM.VALUE=3 when APEL.numval=1 otherwise this AND Condition should not be executed.
One way to do this , if I understood it right :
WHERE APCCL.data = @coolval
          AND CCMF.Status_ID = 1
          AND APCCL.Status_ID = 1
          AND 
          ( 
             (CLM.myval = 3 and APEL.numval = 1)
           or
             (APEL.numval &lt;&gt; 1 )
          )

or try to split in 2 :
SELECT ...
WHERE APCCL.data = @coolval
          AND CCMF.Status_ID = 1
          AND APCCL.Status_ID = 1
          AND CLM.myval = 3 
          AND APEL.numval = 1

UNION  ALL  /* or UNION */

SELECT ...
WHERE APCCL.data = @coolval
          AND CCMF.Status_ID = 1
          AND APCCL.Status_ID = 1
          AND APEL.numval &lt;&gt; 1

Here are some sample testing:
declare @coolVal int = 1;

SELECT *
FROM 
(
SELECT 1 as Data, 1 as Status_ID , 3 as myVal, 1 as numVal UNION ALL
SELECT 1 as Data, 1 as Status_ID , 3 as myVal, 2 as numVal UNION ALL
SELECT 1 as Data, 1 as Status_ID , 4 as myVal, 1 as numVal UNION ALL
SELECT 1 as Data, 1 as Status_ID , 4 as myVal, 2 as numVal 
)a
WHERE
      data = @coolVal
          AND Status_ID = 1
          AND Status_ID = 1
          AND 
    ( 
        (myval = 3 and numval = 1)
        or
        (numval &lt;&gt; 1) 
    )

or with UNION
declare @coolVal int = 1;

SELECT *
FROM 
(
SELECT 1 as Data, 1 as Status_ID , 3 as myVal, 1 as numVal UNION ALL
SELECT 1 as Data, 1 as Status_ID , 3 as myVal, 2 as numVal UNION ALL
SELECT 1 as Data, 1 as Status_ID , 4 as myVal, 1 as numVal UNION ALL
SELECT 1 as Data, 1 as Status_ID , 4 as myVal, 2 as numVal 
)a
WHERE
          data = @coolVal
          AND Status_ID = 1
          AND Status_ID = 1
          AND myval = 3 
          and numval = 1
    
UNION ALL

SELECT *
FROM 
(
SELECT 1 as Data, 1 as Status_ID , 3 as myVal, 1 as numVal UNION ALL
SELECT 1 as Data, 1 as Status_ID , 3 as myVal, 2 as numVal UNION ALL
SELECT 1 as Data, 1 as Status_ID , 4 as myVal, 1 as numVal UNION ALL
SELECT 1 as Data, 1 as Status_ID , 4 as myVal, 2 as numVal 
)a
WHERE
          data = @coolVal
          AND Status_ID = 1
          AND Status_ID = 1
          AND numval &lt;&gt; 1

and the result set :
Data    Status_ID   myVal   numVal
1       1          3        1
1       1          3        2
1       1          4        2

dbfiddle
some interesting info here