Teradata Sql,努力实现利率

Teradata Sql, trying to achieve rate of interest

我试图实现以下结果:

第一行的逻辑是,((470-375)/375)*100 如果有人对此有想法,请贡献。

您可以使用window函数lead()获取下一条记录的cumulative_excp,然后在计算中使用它:

select 
    run_date, 
    cumulative_excp,
    100.0 
        * (lead(cumulative_excp) over(order by run_date) - cumulative_excp) 
        / cumulative_excp interest
from mytable