Hi All,
I am facing issue in my case statemement situation is like this that my siteid ='A' then then dates should be specific target range and if siteid='B' then dates should be in specific range. My query is as follows
select wonum,pmnum,targstartdate,MONTH(targstartdate) as month,commodity,commoditygroup
from workorder where siteid='a'
and workorder.worktype='PM'
and workorder.pmnum is not null
CASE when workorder.siteid='a' then (workorder.targstartdate>'2013-01-01' and workorder.targstartdate<'2014-01-01')
when workorder.siteid='b'
THEN AND (workorder.targstartdate>'2013-01-01' and workorder.targstartdate< '2014-07-01')
ELSE AND (workorder.targstartdate>'2013-01-01')
END
so actually what i am trying to achieve here is when siteid='a' then
CASE when workorder.siteid='a' then (workorder.targstartdate>'2013-01-01' and workorder.targstartdate<'2014-01-01')
and when siteid='b' then
THEN AND (workorder.targstartdate>'2013-01-01' and workorder.targstartdate< '2014-07-01')
Please guide me in this regard. Cheers
I am facing issue in my case statemement situation is like this that my siteid ='A' then then dates should be specific target range and if siteid='B' then dates should be in specific range. My query is as follows
select wonum,pmnum,targstartdate,MONTH(targstartdate) as month,commodity,commoditygroup
from workorder where siteid='a'
and workorder.worktype='PM'
and workorder.pmnum is not null
CASE when workorder.siteid='a' then (workorder.targstartdate>'2013-01-01' and workorder.targstartdate<'2014-01-01')
when workorder.siteid='b'
THEN AND (workorder.targstartdate>'2013-01-01' and workorder.targstartdate< '2014-07-01')
ELSE AND (workorder.targstartdate>'2013-01-01')
END
so actually what i am trying to achieve here is when siteid='a' then
CASE when workorder.siteid='a' then (workorder.targstartdate>'2013-01-01' and workorder.targstartdate<'2014-01-01')
and when siteid='b' then
THEN AND (workorder.targstartdate>'2013-01-01' and workorder.targstartdate< '2014-07-01')
Please guide me in this regard. Cheers