d******y 发帖数: 244 | 1 有一个表
ID NUMBER
1 0
2 1
3 3
4 0
5 4
想得到另外一列 是第二列的累积值
ID NUMBER CUMM
1 0 0
2 1 1
3 3 4
4 0 4
5 4 8
谢谢 | d******y 发帖数: 244 | | j*r 发帖数: 17 | 3 select
ID ,
NUMBER,
(
select sum (NUMBER ) FROM TB B WHERE B.ID<=A.ID
) LEIJI
from TB A | r******s 发帖数: 602 | 4 select
ID ,
NUMBER,
sum(number) over (order by id rows between unbounded preceding and current
row)
from TB a; |
|