求一条累加数据的查询语句
例如:
RQ ACount
2007-1-1 10
2007-1-2 8
2007-1-3 12
2007-1-4 5
....
如何查询得到:
2007-1-1 10
2007-1-2 18
2007-1-3 30
2007-1-4 35
....
------解决方案--------------------select a.rq,(select sum(ACount) from test where rq <= a.rq) from
test test a
order by a.rq
------解决方案--------------------select a.a,sum(b.b)
from test a,test b
where b.a <=a.a
group by a.a
order by a.a
或者
select a.rq,(select sum(ACount) from test where rq <= a.rq)
from test a
order by a.rq
------解决方案--------------------SELECT RQ, SUM(ACount) OVER (ORDER BY RQ) AS TOTAL
FROM tablename