oracle 多字段分组取每组求和

2024-12-15 22:01:38
推荐回答(3个)
回答1:

select t.* ,
sum(统计字段名) over(partition by 分组字段1),
sum(统计字段名) over(partition by 分组字段2),
sum(统计字段名) over(partition by 分组字段3),
......
sum(统计字段名) over(partition by 分组字段n)
from t ;

回答2:

select sum(字段名) from tab_name group by col1,col2,col3

回答3:

select sum(col1),sum(col2),sum(col3) from tab_name group by col1,col2,col3