如何 return 来自下一个分区同一列中计算的值

How to return a value from a calculation in the same column over the next partition

您好,我是 Stack Overflow 的新手,我想知道如何使用 SQL 查询(或 HQL)执行上述操作。

我需要将第 1 列第一行的结果填充到下一行,然后再填充 Column_1。

我希望我的视频能帮助您理解我的问题,因为我运行无法用语言来解释它。

*我没有代码可以开始,因为我想不出任何东西。

谢谢!

你想要的是一种累积乘积,可以使用对数和指数规则来实现,其中规定 log(a * b) = log(a) + log(b)e^log(a) = a

select t.*,
    exp(sum(ln(c)) over (order by date_col)) column_1
from (
    select t.*,
        case when row_number() over (order by date) = 1 then 100 else column_2 end as c
    from your_table t
    ) t