1. 分组累加
eg:
select sum() over(partitionby...orderby...
)
select id,[group],num,sum(num) over(partition by [group] order by id) from testaagroup by id,[group],num
2. 级联求和
select A.username,A.month,max(A.access_time) access_time,sum(B.access_time) accumulate
from
(select username,month,sum(access_time) as access_time from t_access_times group by username,month) A
inner join
(select username,month,sum(access_time) as access_time from t_access_times group by username,month) B
on
A.username=B.username
where B.month<=A.month
group by A.username,A.month
order by A.username,A.month
作用其实是相当于分组累加,都是求截至某个日期的累计求和