🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

sum up column value with group by

User: "mengkoon007"
New Altair Community Member
Updated by Jocelyn

Hi,

 

I have the following columns:

a) id

b) month

c) year

d) value_1

e) value_2

with many other columns.

 

All the values in 'value_1' column, I want to sum up with group by id,month,year.

All the values in 'value_2' column, I want to sum up with group by id,month,year.

 

========

Example Set:

id   month  year     value_1    value_2       

1   Jan       2017     5               6

1   Jan       2017     7               8

1   Feb       2017     8               9

============

 

=============

Expected result:

id   month  year     value_1    value_2       

1   Jan       2017     12             14

1   Feb       2017     8               9

===========

 

I tried to use 1 Aggregate operator with the following input:

  • aggregation attribute (value_1) and aggregation functions (sum), then add entry
  • aggregation attribute (value_2) and aggregation functions (sum), 
  • then select group by attribute id,month,year

 

The following is the result I gotten which is incorrect,

1) There is now only 3 columns - id,value_1,value_2

2) It seems to add up all values with the same id => I need id,month,year matches then sum up

Find more posts tagged with