Reputation: 33
How to update a column adding present value of the column and the new updated value
Example..
If countofcustomer column value is 5 yester and today if v are getting new updated value for
countofcustomer as 2 then the column should get updated as 7.
Upvotes: 0
Views: 221
Reputation: 1867
update table
set value = v.value
from table t join
(Select Sum(value),customer
from table
where month(ENDDATETIME) = month(getdate())
group by customer
)v
on v.customer = t.customer
Upvotes: 1
Reputation: 938
I'm not sure if I correctly understand the question, but maybe trigger could be useful:
You execute an action when an event to a table is raised (like an update).
Upvotes: 0