SELECT A.CODMES PERIODO_CAMPANIA,
       A.PRODUCTO,
	   A.SUBPRODUCTO,
	   A.TIPO_CARGA,
	   A.TIPO_PRODUCTO,
	   T.key_value NUM_DOC,
	   M.key_value NUM_RUC,
	   A.OFERTA,
	   A.PLAZO,
	   A.TASA,
	   A.TASA_PISO,
	   A.SCOREFINAL_BUCKET,
	   A.CANAL_TLV,
	   A.celular1,
	   A.celular2,
	   A.telefono1, 
	   A.telefono2,
	   A.celular_cne,
	   A.celular_cne_2,
	   A.celular_cne_3,
	   A.celular_cne_4,
	   A.celular_cne_5
FROM  DLAB_PROGRAMADATOSVPC.TMP_VMVP_DESPLIEGUE_CAMPANIAS 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.NUM_DOC = T.NRO_DOC AND A.NUM_DOC <> &#039;.&#039; AND A.NUM_DOC IS NOT NULL AND A.NUM_DOC NOT LIKE &#039;&#039;
WHERE 1 = 1
AND A.NUM_RUC <> &#039;.&#039; 
AND A.NUM_RUC IS NOT NULL 
AND A.NUM_RUC NOT LIKE &#039;&#039;
AND A.CODMES = (SELECT MAX(CODMES) FROM DLAB_PROGRAMADATOSVPC.TMP_VMVP_DESPLIEGUE_CAMPANIAS)

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