I want to sum the "amount" column grouped by name and server, and remove duplicate lines. I want those changes are saved (not only with one query).
For example, here is begin data:
And here is what I want:
Actually, I can do it with:
SELECT SUM(amount) as amount FROM myTable GROUP BY server, name;
But, I will only get the value for the amount column. It will not update the table and not remove other lines.
If I do something like
UPDATE myTable SET amount = (SELECT SUM(amount) as amount FROM myTable WHERE server = myTable.server AND name = myTable.name) it will not works as I can't do a select into an update.
So, how can I do?