TB
Num1
1
2
3
4
5
6
如何求出下面的NUM2,1=1,3=1+2,6=1+2+3,10=1+2+3+4,15=1+2+3+4+5,21=。。。。。。
Num1 Num2
1 1
2 3
3 6
4 10
5 15
6 21
------解决方案--------------------
- SQL code
--把上边的id修改为num1,tab改为num1select num1,(select sum(num1)from tb where num1<=t.num1) as a from tb as t