I am trying to select different data from a table depending on what the passed parameter value is. If the parameter is 0 then select all products from plu_file_dates with ToDept value of 60 in the plu_file or else select all products with ToDept of 60 and FromDept with value matching parameter.
However no matter how I try to write the where statement it always fails to execute
DECLARE @Dept AS INT
SET @Dept = 40
SELECT * FROM plu_file_dates
WHERE pluid in (SELECT pluid FROM plu_file WHERE (CASE WHEN @Dept = 0 THEN (ToDept = 60) ELSE (FromDept = @Dept and ToDept = 60) END))