SELECT act_event,
CAST(act_act as varchar(30)) as act_act,
act_note,
act_trade,
act_persons,
CAST(act_est as varchar(30)) as act_est,
act_start,
date(act_start,  CAST(act_duration - 1 as varchar(10)) || ' days') as act_end,
act_task,
TSK_ENABLEENHANCEDPLANNING as act_task_enableenhancedplanning,
tsk_desc as act_task_desc,
act_matlist,
act_completed,
act_rpc,
act_wap,
act_tpf,
act_syslevel,
act_asmlevel,
act_warranty,
act_manufact,
act_matlrev,
act_assignmentstatus,
act_taskrev,
case when (select count(*) FROM r5bookedhours WHERE boo_event=act_event AND boo_act=act_act) = 0 THEN '-' ELSE '+' END as act_hasbooklabor,
case when (select count(*) FROM r5fleetbooklabor WHERE flb_event=act_event AND flb_act=act_act) = 0 THEN '-' ELSE '+' END as act_started,
act_hire,
act_defermaintenance,
act_complocation,
act_udfchar01,
act_udfchar02,
act_udfchar03,
act_udfchar04,
act_udfchar05,
act_udfchar06,
act_udfchar07,
act_udfchar08,
act_udfchar09,
act_udfchar10,
act_udfchar11,
act_udfchar12,
act_udfchar13,
act_udfchar14,
act_udfchar15,
act_udfchar16,
act_udfchar17,
act_udfchar18,
act_udfchar19,
act_udfchar20,
act_udfchar21,
act_udfchar22,
act_udfchar23,
act_udfchar24,
act_udfchar25,
act_udfchar26,
act_udfchar27,
act_udfchar28,
act_udfchar29,
act_udfchar30,
act_udfnum01,
act_udfnum02,
act_udfnum03,
act_udfnum04,
act_udfnum05,
act_udfdate01,
act_udfdate02,
act_udfdate03,
act_udfdate04,
act_udfdate05,
act_udfchkbox01,
act_udfchkbox02,
act_udfchkbox03,
act_udfchkbox04,
act_udfchkbox05
FROM r5activities
LEFT OUTER JOIN r5tasks ON act_task = tsk_code AND act_taskrev=tsk_revision
WHERE act_event = <param.jobnum> and act_act>0









