Here is the query
`select
p.occid,
p.occdate,
f.fillername,
badgeID= null,
p.mc
p.mctime,
problemcode = isnull(p.problemcode,400),
pc.problemdesc,
p.timerresolved,
p.duration,
e.employeename,
pl.durationinminutes,
pl.timein,
pl.timeout,
problemdescription = datediff(minute,occdate,timeresolved)
from problem as p
left join filler as f
on p.fillerid = f.fillerid
left join problemlog as pl
on p.occid = pl.occid
left join problemcode as pc
on p.problemcode = pc.problemcode
left join employee as e
on pl.badgeid = e.id
where f.intials = @fillerselect and
occdate between dateadd(day, datediff(day, '19000101', @startdate),
cast(@starttime as datetime2(7))) and
dateadd(day, datediff(day, '19000101', cast @endtime as datetime2(7)))
and p.problemcode in (@problemcode)
and @Duration <= datediff(minute, occdate, timeresolved)
and case when @reportparameter like 'false'
then e.employeename in (@employee)`
My issue is in the case clause. I get an error stating "incorrect syntax near the keyword 'in'. Does anyone have any ideas how to overcome this?
I should have mentioned that @employee can have multiple selections. When @reportparameter is 'False', then @employee is 'None', stating we are not filtering by employee. When @reportparameter is 'true', we are filtering by employee and @employee may or may not have multiple selections.