with trx_fintech_target as (
    select periodo_val,
        cuc_ordenante_num cuc_envia,
        cuc_beneficiario_num cuc_recibe,
        origen1_moneda_cd moneda,
        origen1_amt monto
    from e_perm_aws.t_fct_transaccion_canal_agg
    where (cuc_ordenante_num <> cuc_beneficiario_num)
        and periodo_val = &#039;{p_2}&#039; -- Fecha +1m
        and (
            cuc_ordenante_num IN (
                &#039;0017819863&#039;,
                &#039;0013838893&#039;,
                &#039;0019177248&#039;,
                &#039;0017281729&#039;,
                &#039;0017038274&#039;,
                &#039;0014896824&#039;,
                &#039;0017643959&#039;,
                &#039;0016204752&#039;,
                &#039;0017631148&#039;,
                &#039;0018026700&#039;,
                &#039;0017751714&#039;,
                &#039;0016705043&#039;,
                &#039;0017735391&#039;,
                &#039;0017872400&#039;,
                &#039;0018238449&#039;,
                &#039;0016208206&#039;,
                &#039;0016587765&#039;,
                &#039;0015410577&#039;,
                &#039;0018332494&#039;,
                &#039;0017883362&#039;,
                &#039;0015791534&#039;,
                &#039;0016973891&#039;,
                &#039;0019024155&#039;,
                &#039;0012078513&#039;,
                &#039;0018133897&#039;,
                &#039;0017758834&#039;,
                &#039;0018967290&#039;,
                &#039;0017363378&#039;,
                &#039;0015562200&#039;,
                &#039;0017692418&#039;,
                &#039;0017077346&#039;,
                &#039;0017695593&#039;,
                &#039;0018251959&#039;,
                &#039;0017570994&#039;,
                &#039;0016306284&#039;,
                &#039;0018878460&#039;,
                &#039;0018106089&#039;,
                &#039;0014208439&#039;,
                &#039;0016138011&#039;,
                &#039;0016466243&#039;,
                &#039;0017049679&#039;,
                &#039;0015833243&#039;,
                &#039;0016403691&#039;,
                &#039;0018397079&#039;,
                &#039;0017904690&#039;,
                &#039;0016724316&#039;,
                &#039;0019638701&#039;,
                &#039;0019287189&#039;,
                &#039;0018648196&#039;,
                &#039;0016241440&#039;,
                &#039;0019880661&#039;,
                &#039;0018040954&#039;,
                &#039;0017883812&#039;,
                &#039;0015072190&#039;,
                &#039;0018133276&#039;,
                &#039;0018582023&#039;,
                &#039;0017810826&#039;,
                &#039;0018216437&#039;,
                &#039;0013264532&#039;,
                &#039;0016979436&#039;,
                &#039;0015899753&#039;,
                &#039;0018958374&#039;,
                &#039;0017850522&#039;,
                &#039;0013078358&#039;,
                &#039;0016060059&#039;,
                &#039;0018630129&#039;,
                &#039;0018158142&#039;,
                &#039;0016384241&#039;,
                &#039;0017129575&#039;,
                &#039;0016116546&#039;,
                &#039;0018885677&#039;,
                &#039;0019191639&#039;,
                &#039;0017762564&#039;,
                &#039;0017128885&#039;,
                &#039;0018782149&#039;,
                &#039;0005876032&#039;,
                &#039;0016416699&#039;,
                &#039;0016153136&#039;,
                &#039;0013441450&#039;,
                &#039;0018131010&#039;,
                &#039;0016713782&#039;,
                &#039;0018930193&#039;,
                &#039;0018578870&#039;,
                &#039;0017063562&#039;,
                &#039;0018508812&#039;,
                &#039;0017314089&#039;,
                &#039;0016143684&#039;,
                &#039;0015743151&#039;,
                &#039;0019167143&#039;,
                &#039;0016179690&#039;,
                &#039;0017334635&#039;,
                &#039;0018118335&#039;,
                &#039;0015471937&#039;,
                &#039;0017493102&#039;,
                &#039;0016134094&#039;,
                &#039;0018027040&#039;,
                &#039;0016049612&#039;,
                &#039;0017321658&#039;,
                &#039;0019635395&#039;,
                &#039;0016216762&#039;,
                &#039;0000041491&#039;,
                &#039;0015075585&#039;,
                &#039;0015973968&#039;,
                &#039;0017058764&#039;,
                &#039;0017136103&#039;,
                &#039;0010626918&#039;,
                &#039;0016120217&#039;,
                &#039;0011948960&#039;,
                &#039;0018261508&#039;,
                &#039;0019658620&#039;,
                &#039;0011457039&#039;,
                &#039;0018079594&#039;,
                &#039;0017612183&#039;,
                &#039;0017829027&#039;,
                &#039;0017455861&#039;,
                &#039;0018625157&#039;,
                &#039;0018401738&#039;,
                &#039;0015338354&#039;,
                &#039;0017668786&#039;,
                &#039;0019558896&#039;,
                &#039;0016974818&#039;,
                &#039;0016039213&#039;,
                &#039;0017822540&#039;,
                &#039;0015675395&#039;,
                &#039;0019156213&#039;,
                &#039;0016052254&#039;,
                &#039;0018565974&#039;,
                &#039;0015942512&#039;,
                &#039;0018675697&#039;,
                &#039;0015813297&#039;,
                &#039;0016081698&#039;,
                &#039;0018210689&#039;,
                &#039;0018518480&#039;,
                &#039;0016096998&#039;,
                &#039;0019087287&#039;,
                &#039;0019211590&#039;,
                &#039;0016068528&#039;,
                &#039;0016189260&#039;,
                &#039;0019355241&#039;,
                &#039;0017028050&#039;,
                &#039;0017380540&#039;,
                &#039;0015935666&#039;,
                &#039;0019114462&#039;,
                &#039;0015997922&#039;,
                &#039;0017744253&#039;
            )
            or cuc_beneficiario_num IN (
                &#039;0017819863&#039;,
                &#039;0013838893&#039;,
                &#039;0019177248&#039;,
                &#039;0017281729&#039;,
                &#039;0017038274&#039;,
                &#039;0014896824&#039;,
                &#039;0017643959&#039;,
                &#039;0016204752&#039;,
                &#039;0017631148&#039;,
                &#039;0018026700&#039;,
                &#039;0017751714&#039;,
                &#039;0016705043&#039;,
                &#039;0017735391&#039;,
                &#039;0017872400&#039;,
                &#039;0018238449&#039;,
                &#039;0016208206&#039;,
                &#039;0016587765&#039;,
                &#039;0015410577&#039;,
                &#039;0018332494&#039;,
                &#039;0017883362&#039;,
                &#039;0015791534&#039;,
                &#039;0016973891&#039;,
                &#039;0019024155&#039;,
                &#039;0012078513&#039;,
                &#039;0018133897&#039;,
                &#039;0017758834&#039;,
                &#039;0018967290&#039;,
                &#039;0017363378&#039;,
                &#039;0015562200&#039;,
                &#039;0017692418&#039;,
                &#039;0017077346&#039;,
                &#039;0017695593&#039;,
                &#039;0018251959&#039;,
                &#039;0017570994&#039;,
                &#039;0016306284&#039;,
                &#039;0018878460&#039;,
                &#039;0018106089&#039;,
                &#039;0014208439&#039;,
                &#039;0016138011&#039;,
                &#039;0016466243&#039;,
                &#039;0017049679&#039;,
                &#039;0015833243&#039;,
                &#039;0016403691&#039;,
                &#039;0018397079&#039;,
                &#039;0017904690&#039;,
                &#039;0016724316&#039;,
                &#039;0019638701&#039;,
                &#039;0019287189&#039;,
                &#039;0018648196&#039;,
                &#039;0016241440&#039;,
                &#039;0019880661&#039;,
                &#039;0018040954&#039;,
                &#039;0017883812&#039;,
                &#039;0015072190&#039;,
                &#039;0018133276&#039;,
                &#039;0018582023&#039;,
                &#039;0017810826&#039;,
                &#039;0018216437&#039;,
                &#039;0013264532&#039;,
                &#039;0016979436&#039;,
                &#039;0015899753&#039;,
                &#039;0018958374&#039;,
                &#039;0017850522&#039;,
                &#039;0013078358&#039;,
                &#039;0016060059&#039;,
                &#039;0018630129&#039;,
                &#039;0018158142&#039;,
                &#039;0016384241&#039;,
                &#039;0017129575&#039;,
                &#039;0016116546&#039;,
                &#039;0018885677&#039;,
                &#039;0019191639&#039;,
                &#039;0017762564&#039;,
                &#039;0017128885&#039;,
                &#039;0018782149&#039;,
                &#039;0005876032&#039;,
                &#039;0016416699&#039;,
                &#039;0016153136&#039;,
                &#039;0013441450&#039;,
                &#039;0018131010&#039;,
                &#039;0016713782&#039;,
                &#039;0018930193&#039;,
                &#039;0018578870&#039;,
                &#039;0017063562&#039;,
                &#039;0018508812&#039;,
                &#039;0017314089&#039;,
                &#039;0016143684&#039;,
                &#039;0015743151&#039;,
                &#039;0019167143&#039;,
                &#039;0016179690&#039;,
                &#039;0017334635&#039;,
                &#039;0018118335&#039;,
                &#039;0015471937&#039;,
                &#039;0017493102&#039;,
                &#039;0016134094&#039;,
                &#039;0018027040&#039;,
                &#039;0016049612&#039;,
                &#039;0017321658&#039;,
                &#039;0019635395&#039;,
                &#039;0016216762&#039;,
                &#039;0000041491&#039;,
                &#039;0015075585&#039;,
                &#039;0015973968&#039;,
                &#039;0017058764&#039;,
                &#039;0017136103&#039;,
                &#039;0010626918&#039;,
                &#039;0016120217&#039;,
                &#039;0011948960&#039;,
                &#039;0018261508&#039;,
                &#039;0019658620&#039;,
                &#039;0011457039&#039;,
                &#039;0018079594&#039;,
                &#039;0017612183&#039;,
                &#039;0017829027&#039;,
                &#039;0017455861&#039;,
                &#039;0018625157&#039;,
                &#039;0018401738&#039;,
                &#039;0015338354&#039;,
                &#039;0017668786&#039;,
                &#039;0019558896&#039;,
                &#039;0016974818&#039;,
                &#039;0016039213&#039;,
                &#039;0017822540&#039;,
                &#039;0015675395&#039;,
                &#039;0019156213&#039;,
                &#039;0016052254&#039;,
                &#039;0018565974&#039;,
                &#039;0015942512&#039;,
                &#039;0018675697&#039;,
                &#039;0015813297&#039;,
                &#039;0016081698&#039;,
                &#039;0018210689&#039;,
                &#039;0018518480&#039;,
                &#039;0016096998&#039;,
                &#039;0019087287&#039;,
                &#039;0019211590&#039;,
                &#039;0016068528&#039;,
                &#039;0016189260&#039;,
                &#039;0019355241&#039;,
                &#039;0017028050&#039;,
                &#039;0017380540&#039;,
                &#039;0015935666&#039;,
                &#039;0019114462&#039;,
                &#039;0015997922&#039;,
                &#039;0017744253&#039;
            )
        )
),
fintech_target as (
    select distinct case
            when cuc_envia in (
                &#039;0017819863&#039;,
                &#039;0013838893&#039;,
                &#039;0019177248&#039;,
                &#039;0017281729&#039;,
                &#039;0017038274&#039;,
                &#039;0014896824&#039;,
                &#039;0017643959&#039;,
                &#039;0016204752&#039;,
                &#039;0017631148&#039;,
                &#039;0018026700&#039;,
                &#039;0017751714&#039;,
                &#039;0016705043&#039;,
                &#039;0017735391&#039;,
                &#039;0017872400&#039;,
                &#039;0018238449&#039;,
                &#039;0016208206&#039;,
                &#039;0016587765&#039;,
                &#039;0015410577&#039;,
                &#039;0018332494&#039;,
                &#039;0017883362&#039;,
                &#039;0015791534&#039;,
                &#039;0016973891&#039;,
                &#039;0019024155&#039;,
                &#039;0012078513&#039;,
                &#039;0018133897&#039;,
                &#039;0017758834&#039;,
                &#039;0018967290&#039;,
                &#039;0017363378&#039;,
                &#039;0015562200&#039;,
                &#039;0017692418&#039;,
                &#039;0017077346&#039;,
                &#039;0017695593&#039;,
                &#039;0018251959&#039;,
                &#039;0017570994&#039;,
                &#039;0016306284&#039;,
                &#039;0018878460&#039;,
                &#039;0018106089&#039;,
                &#039;0014208439&#039;,
                &#039;0016138011&#039;,
                &#039;0016466243&#039;,
                &#039;0017049679&#039;,
                &#039;0015833243&#039;,
                &#039;0016403691&#039;,
                &#039;0018397079&#039;,
                &#039;0017904690&#039;,
                &#039;0016724316&#039;,
                &#039;0019638701&#039;,
                &#039;0019287189&#039;,
                &#039;0018648196&#039;,
                &#039;0016241440&#039;,
                &#039;0019880661&#039;,
                &#039;0018040954&#039;,
                &#039;0017883812&#039;,
                &#039;0015072190&#039;,
                &#039;0018133276&#039;,
                &#039;0018582023&#039;,
                &#039;0017810826&#039;,
                &#039;0018216437&#039;,
                &#039;0013264532&#039;,
                &#039;0016979436&#039;,
                &#039;0015899753&#039;,
                &#039;0018958374&#039;,
                &#039;0017850522&#039;,
                &#039;0013078358&#039;,
                &#039;0016060059&#039;,
                &#039;0018630129&#039;,
                &#039;0018158142&#039;,
                &#039;0016384241&#039;,
                &#039;0017129575&#039;,
                &#039;0016116546&#039;,
                &#039;0018885677&#039;,
                &#039;0019191639&#039;,
                &#039;0017762564&#039;,
                &#039;0017128885&#039;,
                &#039;0018782149&#039;,
                &#039;0005876032&#039;,
                &#039;0016416699&#039;,
                &#039;0016153136&#039;,
                &#039;0013441450&#039;,
                &#039;0018131010&#039;,
                &#039;0016713782&#039;,
                &#039;0018930193&#039;,
                &#039;0018578870&#039;,
                &#039;0017063562&#039;,
                &#039;0018508812&#039;,
                &#039;0017314089&#039;,
                &#039;0016143684&#039;,
                &#039;0015743151&#039;,
                &#039;0019167143&#039;,
                &#039;0016179690&#039;,
                &#039;0017334635&#039;,
                &#039;0018118335&#039;,
                &#039;0015471937&#039;,
                &#039;0017493102&#039;,
                &#039;0016134094&#039;,
                &#039;0018027040&#039;,
                &#039;0016049612&#039;,
                &#039;0017321658&#039;,
                &#039;0019635395&#039;,
                &#039;0016216762&#039;,
                &#039;0000041491&#039;,
                &#039;0015075585&#039;,
                &#039;0015973968&#039;,
                &#039;0017058764&#039;,
                &#039;0017136103&#039;,
                &#039;0010626918&#039;,
                &#039;0016120217&#039;,
                &#039;0011948960&#039;,
                &#039;0018261508&#039;,
                &#039;0019658620&#039;,
                &#039;0011457039&#039;,
                &#039;0018079594&#039;,
                &#039;0017612183&#039;,
                &#039;0017829027&#039;,
                &#039;0017455861&#039;,
                &#039;0018625157&#039;,
                &#039;0018401738&#039;,
                &#039;0015338354&#039;,
                &#039;0017668786&#039;,
                &#039;0019558896&#039;,
                &#039;0016974818&#039;,
                &#039;0016039213&#039;,
                &#039;0017822540&#039;,
                &#039;0015675395&#039;,
                &#039;0019156213&#039;,
                &#039;0016052254&#039;,
                &#039;0018565974&#039;,
                &#039;0015942512&#039;,
                &#039;0018675697&#039;,
                &#039;0015813297&#039;,
                &#039;0016081698&#039;,
                &#039;0018210689&#039;,
                &#039;0018518480&#039;,
                &#039;0016096998&#039;,
                &#039;0019087287&#039;,
                &#039;0019211590&#039;,
                &#039;0016068528&#039;,
                &#039;0016189260&#039;,
                &#039;0019355241&#039;,
                &#039;0017028050&#039;,
                &#039;0017380540&#039;,
                &#039;0015935666&#039;,
                &#039;0019114462&#039;,
                &#039;0015997922&#039;,
                &#039;0017744253&#039;
            ) then cuc_recibe
            else cuc_envia
        end cuc_cliente
    from trx_fintech_target
)
select a.codmes,
    a.tipdoc tip_doc,
    a.coddoc key_value,
    case
        when b.cuc in (
            select cuc_cliente
            from fintech_target
        ) then 1
        else 0
    end target,
    a.puntuacion predicted,
    a.grupo_ejec
from e_perm_aws.scr_tdcfintech a
    inner join (
        select distinct cuc,
            key_value
        from e_perm_aws.t_aws_360_cliente_mes_d3
        where cod_tipo_documento = 1
    ) b on a.coddoc = b.key_value
where a.fecinformacion = &#039;{p_3}&#039; and a.grupo_ejec = 1

Add a code snippet to your website: www.paste.org