change to cte instead of subselects ```
select t1.n as IDN, t1.id as GOLD_ID, decode(md.sign_active, 0, 0, 1) ACTIVE_FLAG, decode(omd.id_record_mdm_new, null, 0, 1) DOUBLING_FLAG
, md2.n as NEW_IDN, omd.id_record_mdm_new NEW_GOLD_ID, UPDATE_DT LAST_CHANGE_DTTM, 0 MAN_FLAG
, TRADEDATE as B_DATE
, t1.IS_MAIN, t1.SHORT_NAME, t1.MEAN_NAME, t1.FULL_NAME, t1.SHORT_NAME_ENG, t1.FULL_NAME_ENG, t1.INN, t1.KPP, t1.KPP_ECBD, t1.OGRN, t1.KPP2, t1.OKATO, t1.OKOGU, t1.OKOPF, t1.OKFS, t1.KIO, t1.OKPO, t1.BIK, t1.BIC_INT, t1.CB_LICENCE_NUMBER, t1.CB_LICENCE_NUMBER_ORIGIN, t1.CB_LICENCE_NUMBER_INT, t1.LEI, t1.FIRMID_MARKET_ID, t1.ECBD_ID, t1.UNICODE, t1.KBD_FIRMID, t1.PROT_ORGID, t1.PROT_ID_AFF1, t1.PROT_ID_AFF2, t1.NAVIGATOR_OTCID, t1.NAVIGATOR_KID, t1.SPECTRA_ID, t1.OMEGA_ID, t1.CFT_ID, t1.GUID_1C, t1.CODE_1C, t1.CODE_RF, t1.CODE_RTS, t1.MOEX_ID, t1.URZH_ID, t1.EXTER_CODE, t1.ERK_ID, t1.ERK_CLIENTID, t1.FININSTID, t1.ID_DAKR, t1.COUNTRY_CODE, t1.REGISTRY_DOC_SERIES, t1.REGISTRY_NUMBER, t1.REGISTRY_NUMBER_2002, t1.REG_NUM_NONRESIDENT, t1.INN_NONRESIDENT, t1.PROT_ORG_TYPE, t1.ORG_STATE, t1.CB_LICENCE_DATE_BEGIN, t1.OGRN_DATE, t1.ADDRESS_F, t1.ADDRESS_Y, t1.ADDRESS, t1.ADDRESS_P, t1.RNR, t1.BANK, t1.CURR_MARKET_ACCEPT_DATE, t1.STOCK_MARKET_ACCEPT_DATE, t1.BROKER_LICENCE_DATE_BEGIN, t1.DEALER_LICENCE_DATE_BEGIN, t1.CONTROL_SEC_LICENCE_DATE_BEGIN, t1.DEPOSITARY_LICENCE_DATE_BEGIN, t1.CURRENCY_MARKET_CATEGORY, t1.STOCK_MARKET_CATEGORY, t1.X_CAN_REPO_CK, t1.WEBSITE, t1.X_RTS_FIRMID, t1.X_STOCK_ADMIT_PAYMENT_DATE, t1.X_STOCK_MARKET_GUARANTEE_FUND, t1.X_UCC, t1.OMEGA_IN_NAV, t1.X_CREATE_DATE, t1.CRM_GUID, t1.FAX, t1.PM_LOGIN_CC, t1.PM_FIO_CC, t1.PM_EMAIL_CC, t1.DL_LOGIN_CC, t1.DL_FIO_CC, t1.DL_EMAIL_CC, t1.CEO_ID, t1.CEO_SURNAME, t1.CEO_FIRSTNAME, t1.CEO_PATRONYMIC, t1.CEO_POSITION, t1.BR_UNSEC_LOAN_MARKET_STATUS, t1.BR_DEPOSIT_MARKET_STATUS, t1.BR_CREDIT_MARKET_STATUS, t1.BR_OFFEX_REPO_MARKET_STATUS, t1.VEB_DEPOSIT_MARKET_STATUS, t1.FT_DEPOSIT_MARKET_STATUS, t1.PF_MARKET_STATUS, t1.CURRENCY_MARKET_STATUS, t1.FORTS_RF_STATUS, t1.ACTIVE_CLIENTS, t1.UT_CURRENCY, t1.UT_STOCK, t1.STOCK_STANDARD_ACCESS_MODE, t1.STOCK_CLASSICA_ACCESS_MODE, t1.CLASSIC_ACCESS_MODE, t1.CLEARING_NCC, t1.FORTS_STATUS, t1.FORTS_STOCK_STATUS, t1.FORTS_MONEY_STATUS, t1.FORTS_COM_STATUS, t1.CM_BUY_SELL_TARIFF_PLAN, t1.CM_SWAP_TARIFF_PLAN, t1.FIRMID_CM, t1.PMT, t1.LISTING_AGENT_STATUS, t1.LISTING_AGENT_STATUS_DATE, t1.SHARES_IN_KS, t1.LISTING_LEVEL, t1.AUTH_CAPITAL_VOL, t1.COMMON_STOCK_NUMBER, t1.COMMON_STOCK_VOLUME, t1.PREF_STOCK_NUMBER, t1.PREF_STOCK_VOLUME, t1.STATE_STOCK_NUMBER, t1.STATE_STOCK_PIE, t1.TOTAL_SHAREHOLDERS_COUNT, t1.VOTE_STOCK_NUMBER, t1.VOTE_STOCK_PIE, t1.FIELDS, t1.HAS_PROFLICENCE, t1.NON_RESIDENT_PIE, t1.REG_DATE, t1.EMAIL, t1.TEL, t1.CURR_CANDIDATE, t1.CURRENCY_ACCESS_MODE, t1.CURRENCY_ACCESS_MODE_ID, t1.CURRENCY_MARKET_ACCEPT, t1.CURR_FORTS_ACCESS_MODE, t1.FORTS_NCC_CLEARING_ACCESS, t1.OTC_ACCESS_MODE, t1.STANDARD_NCC_CLEARING_ACCESS, t1.STOCK_MARKET_ACCEPT, t1.X_GOV_MARKET_STATUS, t1.OTC_ACCESS_STATUS, t1.STOCK_MAIN_NCC_CLEARING, t1.CURR_NCC_CLEARING_ACCESS, t1.STOCK_MARKET_STATUS_TXT, t1.MSF_SMDT, t1.MSF_SCDT, t1.TRADE_DOG_DAT, t1.TRADE_DOG_N, t1.X_IS_PAY_CUSTOMER, t1.CUSTID, t1.EGRN_ID, t1.EGRN_DT, t1.EGRN_STATE, t1.EGRN_STATE_TEXT, t1.EGRUL_ID, t1.TERMINATION_DATE, t1.DB_1C, t1.CODE_OPF, t1.REGISTRY_DATE_2002, t1.OEBS_ID, t1.DIC_OPF, t1.DAKR_RATING, t1.FULL_OPF, t1.TERMINATION_CODE, t1.TERMINATION_NAME, t1.SUCCESSOR_INN, t1.SUCCESSOR_OGRN, t1.SUCCESSOR_NAME, t1.CEO_INN, t1.AUTH_CAPITAL_NOMINAL_COST, t1.AUTH_CAPITAL_TYPE, t1.AUTH_CAPITAL_COST, t1.GICS, t1.BULLETIN_SECTOR_NAME, t1.BULLETIN_SECTOR_NAME_EN, t1.BULLETIN_REGION_NAME, t1.BULLETIN_REGION_NAME_EN, t1.ISINSURER, t1.ERK_OTHERDOCCODE, t1.CURR_FORTS_CLEARING_CATEGORY, t1.OTC_CLEARING_CATEGORY, t1.CROP_CLEARING_CATEGORY, t1.STOCK_AFF, t1.ISCURRENCYLICENSE, t1.STOCK_PROF, t1.VATEXEMPT_FLAG, t1.OKONH, t1.TOWN, t1.IS_SPV, t1.FATCA_ECBD, t1.SHORT_NAME_ESP, t1.FULL_NAME_ESP, t1.INN_ESP, t1.COUNTRY_CODE_ESP, t1.ADDRESS_F_ESP, t1.NOTNULL_NAMES, t1.NOTNULL_IDNUM, t1.DKU_DATE_BEGIN, t1.DKU_DATE_END
, t1.ORG_CATEGORY_ECBD
, OKVED, OKVED_DESCRIPTION, FATCA_KBD
, QCAT, QCAT_PRRISK
, COUNTRY_CODE_F, IS_SMO, SMO_ID, SMO_NAME, SMO_NAME_ENG, SMO_TYPE, SMO_TYPE_NAME
, CODE_LP_INTEGRAL
, CBR_LIC_BRO	
, CBR_LIC_BRO_BEGIN_DATE	
, CBR_LIC_DEA	
, CBR_LIC_DEA_BEGIN_DATE	
, CBR_LIC_DPS	
, CBR_LIC_DPS_BEGIN_DATE	
, CBR_LIC_TRU	
, CBR_LIC_TRU_BEGIN_DATE	
, CBR_LIC_MAN	
, CBR_LIC_MAN_BEGIN_DATE	
, SECTOR, CBR_LIC_ID
, BL_AOO_TRADE_ACCESS_STATUS
, BL_BR_DEP_TRADE_ACCESS_STATUS
, BL_BR_UL_TRADE_ACCESS_STATUS
, BL_FT_DEP_TRADE_ACCESS_STATUS
, BL_PF_TRADE_ACCESS_STATUS
, BL_REPOFK_TRADE_ACCESS_STATUS
, BL_VEB_DEP_TRADE_ACCESS_STATUS
, CR_CLEAR_ACCESS_STATUS
, CR_CLEAR_CATEGORY
, CR_TRADE_ACCESS_STATUS
, CR_TRADE_CATEGORY
, CU_CLEAR_ACCESS_STATUS
, CU_CLEAR_CATEGORY
, CU_TRADE_ACCESS_STATUS
, CU_TRADE_CATEGORY
, DE_CLEAR_ACCESS_STATUS
, DE_CLEAR_CATEGORY
, DE_TRADE_ACCESS_STATUS
, DE_TRADE_CATEGORY
, RTS_CLEAR_ACCESS_STATUS
, RTS_CLEAR_CATEGORY
, RTS_TRADE_ACCESS_STATUS
, RTS_TRADE_CATEGORY_A
, RTS_TRADE_CATEGORY_D1
, RTS_TRADE_CATEGORY_D2
, RTS_TRADE_CATEGORY_F1
, RTS_TRADE_CATEGORY_F2
, RTS_TRADE_CATEGORY_O
, RTS_TRADE_CATEGORY_T1
, RTS_TRADE_CATEGORY_T2
, SD_CLEAR_ACCESS_STATUS
, SD_CLEAR_CATEGORY
, SD_TRADE_ACCESS_STATUS
, SD_TRADE_CATEGORY
, SE_CLEAR_ACCESS_STATUS
, SE_CLEAR_CATEGORY
, SE_TRADE_ACCESS_STATUS
, SE_TRADE_CATEGORY
, CR_CLEAR_START_DATE
, CR_TRADE_START_DATE
, CU_CLEAR_START_DATE
, CU_TRADE_START_DATE
, EDO_MAIL
, RTS_CLEAR_START_DATE
, RTS_TRADE_START_DATE
, SD_CLEAR_START_DATE
, SD_TRADE_START_DATE
, SE_CLEAR_START_DATE
, SE_TRADE_START_DATE, ORG_CATEGORY_NAME_ECBD, ORG_TYPE_ECBD, IS_SZKO , CR_CLEAR_CLOSE_DATE, CR_TRADE_CLOSE_DATE, CU_CLEAR_CLOSE_DATE, CU_TRADE_CLOSE_DATE, DE_CLEAR_CLOSE_DATE, DE_TRADE_CLOSE_DATE, RTS_CLEAR_CLOSE_DATE, RTS_TRADE_CLOSE_DATE, SD_CLEAR_CLOSE_DATE, SD_TRADE_CLOSE_DATE, SE_CLEAR_CLOSE_DATE, SE_TRADE_CLOSE_DATE 
, TRUST_RULE_NUMBER, CONTRACT_TIME, NUMBER_ASSIGNMENT_DATE, PIF_CATEGORY
, RPE_COUNT, IS_SANCTION_LIST_SDN, IS_SANCTION_LIST_SSI
, IS_SANCTION_LIST_RF, IS_SANCTION_LIST_SDN_EU, IS_SANCTION_LIST_SDN_SWISS, IS_SANCTION_LIST_SDN_UK, IS_SANCTION_LIST_SDN_USA
from (
    select unl.tradedate, unl.DATEUNLOAD as LOADDATE, unl.DATEUNLOAD
    , t.*
    , decode ((unl.DATEUNLOAD), max((unl.DATEUNLOAD)) over (partition by t.ID) , 1, 0) AS IS_LAST_CUT
    from moscow_exchange.TV_ENTERPRISE t inner join moscow_exchange.v_unload unl on t.ID_UNLOAD = unl.id
      and t.ID_REFERENCE_MDM   = unl.ID_REFERENCE_MDM
    where unl.ID_REFERENCE_MDM = '9c891856-8cff-4382-a36c-687bdaa44a07' /* 'ENTERPRISE' */ 
) t1 inner join moscow_exchange.master_data md on t1.id = md.id and t1.ID_REFERENCE_MDM = MD.ID_REFERENCE
     left join moscow_exchange.VN_ORIGIN_RECORD_MD omd on md.ID = omd.id_record_mdm_old
     left join moscow_exchange.master_data md2 on omd.ID_REFERENCE = md2.ID_REFERENCE and omd.id_record_mdm_new = md2.ID
 where t1.IS_LAST_CUT=1
   and t1.ID_REFERENCE_MDM = '9c891856-8cff-4382-a36c-687bdaa44a07' /* 'ENTERPRISE' */ 
   and MD.ID_REFERENCE     = '9c891856-8cff-4382-a36c-687bdaa44a07' /* 'ENTERPRISE' */ 
   and MD2.ID_REFERENCE = '9c891856-8cff-4382-a36c-687bdaa44a07' /* 'ENTERPRISE' */ 
;
```