Lena Zheng Asked: 2024-01-10 08:28:25 +0800 CST2024-01-10 08:28:25 +0800 CST 2024-01-10 08:28:25 +0800 CST 下一个营业日期栏 772 我有一个看起来像这样的数据集。 其中business_day指示是否是transaction_created_date工作日。我试图line_amount对假期或周末发生的值进行求和,以便将其添加到下一个工作日,如下所示: 本质上,如果我可以捕获下一个工作日,business_day = 0那么我就可以对分区进行求和。 sum 1 个回答 Voted Best Answer Akina 2024-01-10T16:40:03+08:002024-01-10T16:40:03+08:00 WITH cte AS ( SELECT *, SUM(business_day) OVER (ORDER BY transaction_created_date DESC) num FROM sourcetable ) SELECT *, SUM(line_amount) OVER (PARTITION BY num) business_day_line_amount FROM cte;
1 个回答