如何更新添加列列的現值和新的更新值如何更新一列,每天明智
例..
如果countofcustomer列的值是5的昨天,今天如果V是獲得新的更新值
countofcustomer爲2,則列應得到更新爲7。
如何更新添加列列的現值和新的更新值如何更新一列,每天明智
例..
如果countofcustomer列的值是5的昨天,今天如果V是獲得新的更新值
countofcustomer爲2,則列應得到更新爲7。
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
@ Azar - 我明白月度明智,所以我應該得到本月的客戶數即7月1日至31日。上述查詢也給我上個月的計數。 – user3737182
現在嘗試........ – Azar
我使用在這種狀態下where子句「,其中ENDDATETIME> = DATEADD(DD,DATEDIFF(日,0,GETDATE()),0) 和ENDDATETIME <= DATEADD( DD,DATEDIFF(日,0,GetDate()),30)「但仍然沒有得到更新 – user3737182
請嘗試:
update tbl set countofcustomer=countofcustomer + 2
'更新表設置countofcustomer = countofcustomer + 2' –
@Nikil - 有可以是隨機值一次2個或5個以上,所以我想我不能在查詢 – user3737182
加+2'更新表設置countofcustomer = countofcustomer +(從表中選擇count(*)其中added_date = sysdate)' –