I have a table:
ID type value
a1 income 100
a1 income 70
bb spending 30
bb spending 20
How to sum columns with same ID by value as one row? Se desired results is:
ID type value
a1 income 170
bb spending 50
How to do that?
CodePudding user response:
your_table.groupby['type'].sum()
should do the trick
CodePudding user response:
select id, type, SUM(value)
from table
group by id