Sql server 为什么在sql server 2012中一次添加相同的多个值?

Sql server 为什么在sql server 2012中一次添加相同的多个值?,sql-server,Sql Server,我使用Query计算累积值,如: ..sum(Total) over(order by Total desc) As Cumulative 但它一次计算相同的值 以下是我的输出: Error type Total Cumulative E1 10 10 E2 5 20 E3 5 20 E4 3 26 E5 3 26 我希望: Error t

我使用Query计算累积值,如:

..sum(Total) over(order by Total desc) As Cumulative
但它一次计算相同的值

以下是我的输出:

Error type  Total   Cumulative
E1          10      10
E2          5       20
E3          5       20
E4          3       26
E5          3       26
我希望:

Error type  Total   Cumulative
E1          10      10
E2          5       15
E3          5       20
E4          3       23
E5          3       26

我不知道怎么弄清楚。我想你在找这个

select Error type , Total, 
sum(total) over (order by total desc Rows between Unbounded Preceding and  CURRENT ROW) as Cumulative 
from Table

复制?可能的复制只需将order by更改为:order by[Error type],即可获得所需的输出。检查这个,如果选民能解释为什么这是坏的,它会帮助每个人。对我来说这看起来很糟糕,但我对新的关键词还不够熟悉,无法解释原因。愿意分享吗?@underline\d但它在大多数情况下都能帮助人们。