SELECT
mrc_code department,
mrc_desc deptdescription,
mrc_org deptorganization,
COALESCE (mt.mrt_qty * mt.mrt_hours,0) capavailable,
COALESCE(mt.mrt_tariff,0) rate
FROM r5mrcs m
LEFT OUTER JOIN r5mrctools mt ON m.mrc_code=mt.mrt_mrc and   mt.mrt_tool=COALESCE(<parameter.tool>,'-') and   mt.mrt_org=<control.org>
WHERE coalesce(mrc_notused, '-') <> '+'
AND (<param.bypassdeptsecurity> = 'true'
OR (<parameter.deptsec> ='OFF' OR
(mrc_code IN( SELECT dse_mrc FROM r5departmentsecurity WHERE dse_user =<parameter.r5user> AND dse_mrc = mrc_code AND coalesce(dse_readonly, '-') = '-'))))
