Reputation: 711
I know there has to be a simple answer to this question, but I am a total SQL noob. In my result set I have multiple results in one column that have one specific value that is repeated several times. In another column there is another value that needs to be added. Please see the attached photo for clarification.
I want to be able to find all of the values in Column B that correspond to 'A' and add them up for one result like shown. I want to be sure to delete the duplicates in Column A. Any help is greatly appreciated.
Upvotes: 0
Views: 37
Reputation: 47444
You're trying to SUM
the values in column B and you're trying to group them by (GROUP BY
) the value in column A when you do that. This is accomplished like so:
SELECT
col_a,
SUM(col_b)
FROM
My_Table
GROUP BY
col_a
Upvotes: 4