SQL:计算某列累加合计

ID Score
1 10
2 9
3 8
4 7
5 6
6 5
7 4
8 3
9 2

表格首先是ID升序,Score降序。

select *,(select SUM(score) from test t2 where t2.id<=t.id) as sum1 from test t


猜你喜欢

转载自blog.csdn.net/jyh_jack/article/details/81035116