sql 2012可以用这个(如果a.id不unique,RANGE 和 ROW 稍有不同):
SELECT a.id, a.value, SUM(a.value) OVER (ORDER BY a.id ROWS UNBOUNDED
PRECEDING)
FROM RunTotalTestData a
ORDER BY a.id;
Oracle:
SELECT a.id, a.value, SUM(a.value) OVER (ORDER BY a.id RANGE BETWEEN
UNBOUNDED PRECEDING AND CURRENT ROW)
FROM RunTotalTestData a
ORDER BY a.id;