Home > database >  How to sum values in a column based on values in a different column SQL
How to sum values in a column based on values in a different column SQL

Time:12-08

For example, lets say I have

id values
1 10
1 12
1 10
2 2
2 5
2 4

then i would want sql to return

id values
1 32
2 11

CodePudding user response:

This is very basic sql.

select id, sum(values) as values
from foo
group by id

CodePudding user response:

Select ID,sum(values) From table Group by ID;

  • Related