累加当日、昨日、明日:
select a,b,sum(c) over(partition by a order by b rows between 1 preceding and 1 following) from t
累加当日和昨天:
select a,b,sum(c) over(partition by a order by b rows between 1 preceding and current row) from t
累加历史:分区内当天及之前所有
select a,b,sum(c) over(partition by a order by b) from t
或者:
select a,b,sum(c) over(partition by a order by b rows between unbounded preceding and current row) from t
累加分区内所有:当天和之前之后所有
select a,b,sum(c) over(partition by a order by b rows between unbounded preceding and unbounded following) from t
网友评论