select ifnull(ack_code, (act.rowid + tch_sequence) * -1) as checklistcode,
ack_completed as completed,
ack_updated as dateupdated,
tch_desc as description,
ack_notes as notes,
ack_updatecount as recordid,
tch_sequence as sequence,
ack_updatedby as updatedby
FROM r5activities act 
JOIN r5taskchecklists tl
   ON act.ACT_TASK = tl.TCH_TASK 
JOIN r5tasks ts
   ON act.ACT_TASK = ts.TSK_CODE AND ts.TSK_ACTIVECHECKLIST = '+'
LEFT OUTER JOIN R5actchecklists acl
   ON act.ACT_EVENT = acl.ACK_EVENT 
       and act.ACT_ACT = acl.ACK_ACT 
       and tl.TCH_SEQUENCE = acl.ACK_SEQUENCE
where act.ACT_EVENT = <param.workordercode> 
and act.ACT_ACT = <param.activitycode>
order by sequence