我有一张桌子ZXC
select NAME, MONTH, YEAR, DEPT, MONTHVAL, YEARVAL from ZXC
该列MONTHVAL
有一些值。我想根据名称、部门和月份的组合聚合一些行,并在YEARVAL
列中显示聚合值。
例如,如果我有桌子
Name Month Year Dept Monthval Yearval
BLAKE Jan 2011 100 124.542 0
KING Feb 2011 200 234.542 0
KING Jan 2011 200 27764.464 0
BLAKE March 2011 100 0 0
BLAKE Feb 2011 400 0 0
SCOTT Jan 2011 500 24564.464 0
KING March 2011 200 1265.542 0
KING April 2011 200 1065.542 0
然后我想看到结果
Name Month Year Dept Monthval Yearval
BLAKE Jan 2011 100 124.542 124.542
KING Jan 2011 200 27764.464 27764.464
SCOTT Jan 2011 500 24564.464 24564.464
KING Feb 2011 200 234.542 27999.006
BLAKE Feb 2011 100 0 124.542
KING March 2011 200 1265.542 29264.548
BLAKE March 2011 100 0 124.542
KING April 2011 200 1065.542 30330.09