I’m using SQL Server 2008.
This is my data:
column1 columnAmount
-----------------------
ab 3
ac 2
ab 4
So in my query I want to sum the values which are the same in the colum1.
My desired output would be:
column1 columnAmount
----------------------
ab 7
ac 2
How can I do this?
This is a basic
SUM ... GROUP BYAs the syntax suggests it divides the input into groups (one for each distinct value of
column1) and calculates the sum for each group.