-- RECARGA
SELECT dd.codmes,
case when length(dd.num_ruc_hash) < 64 then dd.num_ruc_hash else hh.nro_doc end nro_doc,
case when length(dd.num_telefono) < 64 then dd.num_telefono else tt.nro_telef end nro_telef,
dd.motivo_oportunidad,
dd.hoy fec_proceso
from aws_unicorn_comercial.disc_comercial.hm_4_recarga_x_modelos_sg dd
left join teradata.e_dw_views.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA hh
on dd.num_ruc_hash = hh.key_value
left join teradata.e_dw_views.V_MST_ENCRIP_NROTELEF_MDL_HIST tt
on dd.num_telefono = tt.telef_value
where dd.codmes = '202512' -- cambiarAdd a code snippet to your website: www.paste.org