MYSQL how to sum rows with same key, then delete the duplicate rows

Posted by Bhante-S on Stack Overflow See other posts from Stack Overflow or by Bhante-S
Published on 2013-06-30T04:05:41Z Indexed on 2013/06/30 4:21 UTC
Read the original article Hit count: 102

Filed under:
|

What I have:
key data
1      22
1       5
2       6
3       1
3      -3

What I want:
key data
1      27
2       6
3      -2

I don’t mind doing this with two or more queries, esp. if they are simple--makes for easier maintenance. Also the tables are fairly small (<2,000 records). The ‘key’ field is indexed and allows duplicates.

Muchas Gracias

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sum