oracle行结果合计的实现,主要应用于日期结果的集计,下面是具体的实现代码。
with aa as (
select ‘a’ tno , 10 b from dual
union
select ‘b’ , 20 from dual
union
select ‘a’ , 30 from dual
)
select tno , sum(b) over (partition by b order by b rows unbounded preceding) sumsal from aa
备注
还可以有rows 2 preceding的写法,就是集计到第五行。