Good morning People, I need the column "Expenses" to be added as new records are being entered. Try to do it with an update, I work in mysql but doing it in sql server throws me an error. The sales id is with the number 3 because before loading it, load 2 records in the table.
The table as I would like it to remain would be like this:
+----------+-------+----------+
| IdVentas | Mes | Gasto |
+----------+-------+----------+
| 1 | 1 | 10 |
| 2 | 1 | 20 |
| 3 | Acum. | 30 |
+----------+-------+----------+
I await your comments. Greetings
UPDATE
ventas v,
(SELECT sum(gasto) as mysum
FROM ventas
where idventas <> 3
) as s
SET
v.gasto = s.mysum
WHERE
v.idventas = 3