This will return the total work order labor cost for a certain work order completion date for all equipment or for the selected equipment for the last 3 full months, excluding the current month.
SELECT evt_completed as "Completion Date",
SUM(evo_labor) as "Labor"
FROM r5events, r5eventcost
WHERE evt_code = evo_event
AND evt_completed >= ADD_MONTHS( LAST_DAY( TRUNC( SYSDATE ) ) + 1, - 4 )
AND evt_completed < ADD_MONTHS( LAST_DAY( TRUNC( SYSDATE ) ) + 1, - 1 )
AND evt_object LIKE COALESCE( :OBJECT , '%' )
AND evt_object_org LIKE COALESCE( :OBJECTORG , '%' )
GROUP BY evt_completed
ORDER BY 1