SELECT rel.world_id, rel.WORLD_NAME, rel.WORLD_DESC,
	   proj.proj_name, vt.vtree_name, rt.rtag_name, rt.OFFICIAL,
	   rt.rtag_id, pv.pv_id, pkg.pkg_name, pv.pkg_version, 
	   DECODE(rel.world_id,
	   		  NULL, DECODE (rt.rtag_id,
			  			    :RTAG_ID, 'checked',
							NULL ), 
			  myw.checked
			  ) AS checked,
	   DECODE(pv.pv_id,
	          :PV_ID, 'form_item',
			  'err_alert'
	         ) AS version_style
  FROM release_content rc,
  	   release_tags rt,
	   vtrees vt,
	   projects proj,
       package_versions pv,
	   package_versions opv,
	   packages pkg,
	   (
	      SELECT MAX(rtag.rtag_id) AS rtag_id, rtag.vtree_id, wd.WORLD_ID, wd.WORLD_NAME, wd.WORLD_DESC
		    FROM release_tags rtag,
				 vtrees_world vtw,
				 worlds wd
		   WHERE rtag.vtree_id = vtw.VTREE_ID (+)
		     AND vtw.WORLD_ID = wd.WORLD_ID (+)
	 	   GROUP BY rtag.VTREE_ID, wd.WORLD_ID, wd.WORLD_NAME, wd.WORLD_DESC
	   ) rel,
	   ( 
	     /* Find My World for RTAG_ID */
	     SELECT 'checked' AS checked, vtw.world_id, rt.rtag_id
	       FROM vtrees_world vtw,
		   		release_tags rt
		  WHERE rt.VTREE_ID = vtw.VTREE_ID
			AND rt.rtag_id = :RTAG_ID
	   ) myw
 WHERE rt.VTREE_ID = vt.VTREE_ID
   AND rc.rtag_id = rt.rtag_id
   AND rc.pv_id = pv.pv_id
   AND vt.PROJ_ID = proj.proj_id
   AND vt.HIDE = 'N'
   AND rt.rtag_id = rel.rtag_id   
   AND opv.pv_id = :PV_ID
   AND pv.pkg_id = pkg.pkg_id
   AND opv.pkg_id = pv.pkg_id
   AND NVL(opv.v_ext, '|LINK_A_NULL|') = NVL(pv.v_ext, '|LINK_A_NULL|')
   AND myw.world_id = rel.world_id
   /*------- OFFICIAL FILTER ----- */
   AND (    ( rt.OFFICIAL = 'N' AND :OFFICIAL_FILTER = 0 )	   -- Show Unofficials 
         OR ( rt.OFFICIAL = 'Y' AND :OFFICIAL_FILTER = 1 )	   -- Show Officials
  	     OR ( :OFFICIAL_FILTER = -1 ) 				   	 	   -- Show All
	   )
   /*------------------------------*/
ORDER BY UPPER(rel.world_name), UPPER(proj.proj_name), UPPER(vt.vtree_name), UPPER(rt.rtag_name)