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
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