user3737182
user3737182

Reputation: 33

How to update a column on daily wise

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

Answers (3)

Azar
Azar

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

TechDo
TechDo

Reputation: 18629

Please try:

update tbl set countofcustomer=countofcustomer + 2

Upvotes: 0

insilenzio
insilenzio

Reputation: 938

I'm not sure if I correctly understand the question, but maybe trigger could be useful:

msdn trigger:

You execute an action when an event to a table is raised (like an update).

Upvotes: 0

Related Questions