MySQL Forums
Forum List  »  Newbie

Re: Carry out SUM and place result into a different table
Posted by: Peter Brawley
Date: May 02, 2020 10:48AM

On the Select query ...

select a,b,c,sum(e),sum(f),sum(g)
...
group by a ...

... will give arbitrary results for b and c, you need ...

group by a,b,c ...

To update a second table, you'll need a primary key value for that table unambiguously identifying which row to update, then you can write something like ...

update sumtbl a
join ( the above query ) b on ...
where ...

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.