the close channel is derived in the following sub query
left outer join
( select distinct new_opportunityid
from stg.v_contractactions ca
join stg.v_tbltransmaster tm on ca.vcmembertransnumber=tm.vctransactionnumber
and ca.source_system_id=tm.source_system_id
join stg.esp_new_contractactions eca on ca.icontractid=eca.new_name
join stg.bs_tbl_facility b on b.code=eca.new_vchomefacilityid
and b.companyid=ca.company_id