一个更新语句,总计增加100

时间:2015-04-28 22:24:04

标签: sql sql-server sql-update

我如何编写一份更新声明,为一年中第一年编写的所有发票的发票的信用总额字段增加100?

我试图写一个如下声明:

 Update dbo.invoices
 set credittotal (this is the problem right here where i dont know how to     add       100 to this)
 where invoices = (the first of the year)

1 个答案:

答案 0 :(得分:3)

添加100意味着列的新值将是当前值加上100:

UPDATE dbo.invoices
SET    credittotal = credittotal + 100
WHERE  DATEPART (dy, invoices) = 1
相关问题