SELECT A.periodo, A.campania,
T.KEY_VALUE coddoc, M.KEY_VALUE num_ruc,
A.scorefinal_nr, A.primariesgo, A.oferta_calculada, A.rmaactual_bpe_final, A.rmaactual_consumo,
A.cemoferta, A.CEMOPERATIVO, A.costo_fondo_real, A.costo_fondo_redondeado, A.gasto_operativo,
A.margen_comercial, A.tasapiso_real, A.tasapiso_redondeado
FROM DLAB_PROGRAMADATOSVPC.TMP_VMVP_CAMPANIA_BPE_FROM_RIESGOS A
LEFT JOIN E_DW_VIEWS.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA M
ON A.NUM_RUC = M.NRO_DOC
LEFT JOIN E_DW_VIEWS.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA T
ON A.CODDOC = T.NRO_DOC AND A.CODDOC <> '.' AND A.CODDOC IS NOT NULL AND A.CODDOC NOT LIKE ''
WHERE 1 = 1
AND A.NUM_RUC <> '.'
AND A.NUM_RUC IS NOT NULL
AND A.NUM_RUC NOT LIKE ''
--AND A.PERIODO = (SELECT MAX(PERIODO) FROM DLAB_PROGRAMADATOSVPC.TMP_VMVP_CAMPANIA_BPE_FROM_RIESGOS)
AND A.NUM_RUC IN (SELECT NUM_RUC FROM DLAB_PROGRAMADATOSVPC.TMP_VMVP_RECARGA_RIESGOS)
Add a code snippet to your website: www.paste.org