知道可以使用什么功能或逻辑来实现此输出?

发布于 2025-01-23 21:40:28 字数 280 浏览 0 评论 0原文

问题:

表A具有一个带有4个值

col 1
-----
1
2
5
8

输出

col 1  col 2
-----  -----
    1      2
    2     10
    5     40
    8      8

的一列,应该是现有的列,该列具有累积产品的派生列。当没有更多值可乘以时,应按原样显示行值。累积总和可以轻松计算。知道如何实现乘法吗? 我尝试使用OLAP功能,但没有运气。

Question:

Table A has one column with 4 values

col 1
-----
1
2
5
8

Output

col 1  col 2
-----  -----
    1      2
    2     10
    5     40
    8      8

Output should be the existing column with a derived column that is a cumulative product. When there are no more values to multiply with, the row value should be displayed as is. Cumulative sum can be calculated easily. Any idea how multiplication can be achieved?
I tried using OLAP functions, but no luck.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦毁影碎の 2025-01-30 21:40:28

您的预期输出是当前和下一行的产物:

col1 * lead(col1,1,1) over (order by col1)

Your expected output is the product of the current and the next row:

col1 * lead(col1,1,1) over (order by col1)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文