sql - Update duplicated records MySQL -


i have table this:

q  b 1  0 1 1  2 0 2  3 0 2  0 4 

and want this:

q  b 1  2 1 1  2 1 2  3 4 2  3 4 

and remove duplicated values. idea how this? have duplicated value of q saved in table if helps :)

you need group table suitable aggregate function (i use sum() below, may want use max() or else, depending on requirements):

select   q, sum(a) a, sum(b) b     my_table group q 

see on sqlfiddle.


Comments