select t.creator 建單人,
t.titles 工單主題,
t.statusdisplay 工單狀態,
t.serialnumber 流水號
from up_itsm_iss t join v_depart_info rt on t.creatorid=rt.USERID
where
(('小計'='{3}' and t.iss_class like '%{4}%' )
or (rt.CNAME like '{3}' and t.iss_class like '%{4}%'))
and t.creator <> 'root' and (t.statusdisplay <> '已作廢' or t.statusdisplay is null)