Oracle SQL添加列,总列按其他字段分组
我有这个结果Oracle SQL添加列,总列按其他字段分组,sql,oracle12c,Sql,Oracle12c,我有这个结果 ZONE SITE BRAND VALUE north a a_brand1 10 north a a_brand2 15 north a a_brand3 27 south b b_brand1 17 south b b_brand2 5 south b b_brand3 56 是否有任何方法可以添加一列,其中包含按区域和站点分组
ZONE SITE BRAND VALUE
north a a_brand1 10
north a a_brand2 15
north a a_brand3 27
south b b_brand1 17
south b b_brand2 5
south b b_brand3 56
是否有任何方法可以添加一列,其中包含按区域和站点分组的总和?这样:总场地a=10+15+27=52,总场地b=17+5+56=78
ZONE SITE BRAND VALUE TOTAL_IN_SITE
north a a_brand1 10 52
north a a_brand2 15 52
north a a_brand3 27 52
south b b_brand1 17 78
south b b_brand2 5 78
south b b_brand3 56 78
谢谢。使用
sum
窗口功能
select t.*,sum(val) over(partition by zone,site)
from tbl t
使用
sum
窗口函数
select t.*,sum(val) over(partition by zone,site)
from tbl t
美好的非常感谢。很好!。谢谢。