>UPDATE cAgent ; > SET yMonth = dtSum.yMonth ; > FROM cAgent ; > JOIN ; > (SELECT SUM(yAmount) AS yMonth, ; > iAgentID, MONTH(dDate) AS nMonth, ; > Year(dDate) AS nYear ; > FROM cMovs ; > GROUP BY iAgentID, nMonth, nYear) dtSum ; > ON dtSum.iAgentID = cAgent.iID ; > AND dtSum.nMonth = cAgent.nMonth ; > AND dtSum.nYear = cAgent.nYear >>>Lets supose I have a table with every entry in the system:
--sb--