select 
cast(a.act_act as varchar(30)) as workorderactivity,
a.act_trade as tradecode
FROM r5activities a, r5events e 
WHERE e.evt_code=a.act_event and 
a.act_event = <workorder_code> AND
(a.act_defermaintenance  = '-' OR  <transaction_type> = 'RETURN'  )
