/* Bom Tree Combo */ 
SELECT distinct
       bo.BOM_ID,
       bo.BOM_VERSION ||'.'|| bo.BOM_LIFECYCLE AS BOM_VERSION,
       bn.BOM_NAME,
       DECODE ( :BOM_ID, bo.BOM_ID, 'selected', NULL ) AS SELECTED 
FROM (
       SELECT bo.BOM_ID,
              bo.BOM_VERSION ||'.'|| bo.BOM_LIFECYCLE AS VERSION
       FROM   BOMS bo,
              BOM_STATE bs,
              PRODUCTION_BOM pm
       WHERE  bo.BRANCH_ID = :BRANCH_ID
         AND  bs.STATE_ID  = pm.STATE_ID
         AND  bs.BOM_ID    = bo.BOM_ID
     ) qry,
       BOMS bo,
       BOM_NAMES bn 
WHERE qry.BOM_ID = bo.BOM_ID 
  AND bn.bom_name_id = bo.bom_name_id
  AND (bo.is_rejected IS NULL OR bo.IS_REJECTED = 'N')
ORDER BY bom_version desc
