Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 列FINAL_value中上一行的累积值_Sql_Sql Server_Tsql_Ssms_Window Functions - Fatal编程技术网

Sql 列FINAL_value中上一行的累积值

Sql 列FINAL_value中上一行的累积值,sql,sql-server,tsql,ssms,window-functions,Sql,Sql Server,Tsql,Ssms,Window Functions,我的表名是“fundt”,我的问题是: 如何计算列FINAL_值中上一行的累计和?” 我认为交叉连接是可能的,但我不知道怎么做 我怀疑您想要具有窗框的窗口功能: select t.*, sum(final_value) over( order by it_month rows between unbounded preceding and 1 preceding ) cumulative_final_value from myta

我的表名是“fundt”,我的问题是:

如何计算列FINAL_值中上一行的累计和?”

我认为交叉连接是可能的,但我不知道怎么做


我怀疑您想要具有窗框的窗口功能:

select
    t.*,
    sum(final_value) over(
        order by it_month 
        rows between unbounded preceding and 1 preceding
    ) cumulative_final_value
    from mytable t
这将为您提供前几行(不包括当前行)的累积
sum(),使用列
it\u month
进行订购。您可能需要根据您的确切需求调整此列,但这似乎是您所寻找的逻辑。

什么的累积总和?请解释
最后一年的计算规则
,查看您的数据并不明显。请阅读一些关于改进您的问题的提示在…上