Oracle行结果合计的实现

Posted on 2020-02-23 22:31  wzhw2015  阅读(325)  评论(0编辑  收藏

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的写法,就是集计到第五行。

posts - 32, comments - 0, trackbacks - 0, articles - 0

Copyright © 2020 wzhw2015
Powered by .NET 5.0.0-rc.2.20475.5 on Kubernetes