SELECT crw_code,
      crw_desc,
      crw_org
 FROM r5crews,
      r5userorganization
WHERE
      COALESCE(crw_notused, '-') = '-' AND
      crw_org = uog_org AND
      uog_user = <parameter.r5user> AND
      EXISTS (select * from r5crewemployees where crw_code = cre_crew AND
      crw_org = cre_crew_org) AND
      (uog_common = '+' OR
       uog_org = <parameter.org>) AND
       DATE(IFNULL(CRW_EXPIRATIONDATE,DATE('now'))) >= DATE('now')
ORDER BY crw_code ASC,
         crw_org ASC;
