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 ( 3 years ago )
SELECT periodo, num_ruc,
max(flg_desembolso) flg_desembolso,
max(CASE WHEN order_tasa = 1 and flg_desembolso = 1 then tasa_desembolsada
WHEN order_tasa = 1 and flg_desembolso = 0 then tasa_piso
ELSE NULL END
) tasa_final
FROM (
select *,
row_number() over (
partition by periodo, num_ruc order by
(case when flg_desembolso = 1 and tasa_desembolsada is not null then 0
else tasa_piso end
) asc
) order_tasa
FROM d_mdl_vpc_disc.UNIVERSO_PRICING_SUNAT
)
GROUP BY periodo, num_ruc
Revise this Paste