Question : Update data and select from same table

Can I do something like this. Theres error in the query below though:

UPDATE transac
SET
balance = (SELECT (invoice - SUM(payment)) AS balance FROM transac) z
GROUP BY z.idinvoice
WHERE z.idinvoice = @idinvoice

Answer : Update data and select from same table

Random Solutions  
 
programming4us programming4us