Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as SQL by registered user vvillacorta ( 8 months ago )
DELETE FROM DLAB_MODELOS.TMP_JTT_CREDITOS_SDA;
INSERT INTO DLAB_MODELOS.TMP_JTT_CREDITOS_SDA
WITH MAXIMA_FECHA as(
SELECT MAX(FecInformacion_Dt) max_fec_del_mes
FROM E_DW_VIEWS.V_MST_SDA_SOLICITUD
WHERE CAST(CAST(FecInformacion_Dt AS FORMAT 'YYYYMM') AS VARCHAR(6)) = (SELECT MAX(PERIODO) FROM DLAB_MODELOS.HM_LAST_MONTH)
)
SEL a.FecInformacion_Dt, a.Cod_Unico_Val, a.Solicitud_Cd, a.Credito_Cd
, a.Fecha_Desemb_Dt, a.RegEjecutivo_Val, a.Reg_EjecutivoInicial_Val, a.Centro_Val
, a.SubProducto_Val
, case when a.SubProducto_Val like '30K REACTIVA PERU REPROG 2022' then 1 else 0 end FLG_Reactiva_Repro_22
, case when a.SubProducto_Val like '30K REACTIVA PERU REPROG' then 1 else 0 end FLG_Reactiva_Repro
, case when a.SubProducto_Val like '30K REACTIVA PERU' and a.SubProducto_Val not like '%REPROG%' then 1 else 0 end FLG_Reactiva
, case when a.SubProducto_Val like 'COFIDE FONDO CRECER' then 1 else 0 end FLG_Crecer
, case when a.SubProducto_Val like 'CAPITAL%TRABAJO%' and A.Centro_Val not in ('CIMA VISA') then 1 else 0 end FLG_Capital_Trabajo
, case when a.SubProducto_Val like 'LINEA%' then 1 else 0 end FLG_Linea
, case when A.Centro_Val in ('CIMA VISA') then 1 else 0 end FLG_CIMA
, row_number () over (partition by a.Cod_Unico_Val order by a.Solicitud_Cd desc ) Orden
from E_DW_VIEWS.V_MST_SDA_SOLICITUD a
where a.FecInformacion_Dt = (SEL MAX(max_fec_del_mes) from MAXIMA_FECHA)
--and a.Credito_Cd <> ''
and a.Estado_SolCre_Val in ('VIGENTE','VENCIDA')
and a.Centro_Val <> 'RECUPERACIONES'
and (
(a.SubProducto_Val like 'LINEA%REVOLVENTE%' and COALESCE(a.Saldo_Pri_Amt, 0) >= 0) OR a.Saldo_Pri_Amt > 0
)
Revise this Paste