I am trying to update an invoice total on an invoice table from the lineitem totals on an invoice details table. I'm finding using an aggregate function within an update query is challenging.
I'm adding these total fields to make it easier for management to gather stats in our small firm.
Here is the SQL that I think should work but it not working and throwing a: "Syntax Error (missing operator) in query expression 't.total from tblPO p inner join..."
SET p.PO_total = t.total FROM tblPO p
(SELECT tblPO_Details.PO_ID, SUM(tblPO_Details.subtotal) as total
GROUP BY tblPO_Details.PO_ID) as t
ON t.PO_ID = p.PO_ID