You are correct. The syntax is not allowed. You can try:
((@IncludePTO = 'Y' and dbo.PRTH.EarnCode IN (1,2,3,8,100,110,120,115)) or
(@IncludePTO <> 'Y' and dbo.PRTH.EarnCode IN (1,2,3,8))
)
This can be simplified to:
(bo.PRTH.EarnCode IN (1,2,3,8) or (@IncludePTO <> 'Y' and dbo.PRTH.EarnCode IN (100,110,120,115))
)
This assumes that @IncludePTO is never NULL. If so, then that would have to be part of the test.
If you really want case statement in the where
clause, you can do:
(CASE WHEN @IncludePTO = 'Y' and dbo.PRTH.EarnCode IN (1,2,3,8,100,110,120,115)
then 'true'
when @IncludePTO <> 'Y' and dbo.PRTH.EarnCode IN (1,2,3,8)
then 'true'
else 'false'
end) = 'true'