I want to use CASE in WHERE clause, but it returns error.
Can I use CASE in where clause? or how to fix it ? Thanks
SELECT * FROM hris_leave.dbo.tbl_act
inner join hris_leave.dbo.tstaff on hris_leave.dbo.tstaff.s_id = hris_leave.dbo.tbl_act.s_id
where
case when acting_to is not null
then
datediff(day, acting_from, acting_to) >= 90 and acting_to >= '2010-10-01'
else
acting_to is null
order by hris_leave.dbo.tbl_act.s_id
In your case, you only need OR
A case is for values, not conditions. The condition is outside the CASE expression
eg