select
coalesce(
(coalesce(
(select coalesce(act_qty,1)  FROM   r5activities  WHERE  act_event = <param.eventno> AND act_act =<param.act>)
,1) * tsk_hours)
, <param.esthrs>) as esthrs,
IFNULL(tsk_persons,<param.personsreq>) as pplreq,
TSK_CODE as task,
tsk_desc as taskdesc,
t.tsk_org as taskorganization,
TSK_REVISION as taskrev,
tsk_uom as taskuom,
IFNULL(tsk_trade, <param.trade>) as trade,
TSK_REVISION as taskrev,
TSK_RPC as reasonforrepair, TSK_WAP as workaccomplished, TSK_TPF as techpartfailure, TSK_SYSLEVEL as syslevel, TSK_ASMLEVEL as asslevel, TSK_COMPLEVEL as complevel,
tsk_manufact as manufacturer
from r5tasks t, r5userorganization u where t.tsk_revrstatus = 'A'
and t.tsk_org = u.uog_org     and u.uog_user = <parameter.r5user>
and (u.uog_common = '+' or u.uog_org = <control.org>)
and coalesce(t.tsk_notused, '-') <> '+' and  (t.tsk_enableenhancedplanning IS NULL OR t.tsk_planninglevel IS NOT NULL)
and coalesce(t.tsk_jobplan,'-')='-' and  coalesce(t.tsk_isolationmethod, '-') <> '+'
