I am not a frequent mysql user, but I do know commands enough to get my work done.
I have a table that has say 3 fields, Unique_Key, Number_cnt, Total_number
.
The table is filled with unique key and number but total number is kept blank. Say table looks like this.
A | 10 | NULL
A | 25 | NULL
A | 33 | NULL
B | 13 | NULL
D | 11 | NULL
D | 22 | NULL
Is there a sql way of updating the last column with the sum of the numbers grouped by the unique key.
End table like this:
A | 10 | 68
A | 25 | 68
A | 33 | 68
B | 13 | 13
D | 11 | 33
D | 22 | 33
I do know the query to generate the result
select unique_key,sum(number_cnt) from mTable group by unique_key;
What I am looking for is a way to auto fill the column.
Thanks !