Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so dont bother with any of their useless mail servers here and just use oauth login instead. Thank the nice Russians for causing that. :)

Paste

Pasted as SQL by registered user vvillacorta ( 4 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

Your Name: Code Language: