select 
m.mrc_code as department,
m.mrc_desc as des_text,
m.mrc_schedgroup as supervisor_code 
from r5mrcs m, r5userorganization u where  
  m.mrc_org = u.uog_org and
 u.uog_user = <parameter.r5user>  and  
( u.uog_common = '+' or u.uog_org = <control.org>  ) and 
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, '-') = '-'))))
