I have a tab with Agents and fields |ID_Agent | City | Payment| , i want to set their payments as a part of the sum of all agents in the concrete town.
UPDATED
To make shorter there is another call, but anyway, it doesn't work
UPDATE Agent as a1
SET a1.Payment=
(SELECT AVG(a2.Payment) FROM Agent as a2 WHERE a2.City= a1.City)
I have read that it should work, but it doesn't so i don't know how to make this thing work
How it supposed to be:
Original table |ID_Agent | City | Payment| |1 |London| 1600 | |2 |York | 2000 | |3 |London| 1000 | |4 |York | 1500 |
Result table |ID_Agent | City | Payment| |1 |London| 1300 | |2 |York | 1750 | |3 |London| 1300 | |4 |York | 1750 |