select COALESCE(evt_parent, evt_code) workorder,evt_desc description,
evt_org organization,CASE WHEN evt_parent IS NOT NULL THEN evt_code ELSE NULL END relatedworkorder FROM r5events, r5userorganization
WHERE evt_org = uog_org AND uog_user = <parameter.r5user>
AND evt_object = <parameter.equipment> AND evt_object_org = <parameter.equipmentorg>
order by COALESCE(evt_parent, evt_code) DESC
