select
c.crw_code as crew,
c.crw_desc as crewdesc,
c.crw_org as creworganization,
c.crw_expirationdate crewexpiration
from r5crews c, r5userorganization u where
c.crw_org= u.uog_org and u.uog_user = <parameter.r5user> and
( u.uog_common = '+' or u.uog_org = <control.org> ) and coalesce(c.crw_notused, '-') = '-' and DATE(IFNULL(CRW_EXPIRATIONDATE,DATE('now'))) >= DATE('now')
