SQL 根据另一个字段的条件更新字段

SQL update field based on conditions of another field

这里是超级菜鸟。

我想在列 Delete_Field = C 时将列 AI_Amount 更新为 0。

当客户离开时,delete_field 会更新为 C,但 AI_Amount 字段不会清零。我该怎么做?

我尝试使用更新子句,但它说我没有权限。我不想只更新查询结果 table。

I don't want to update the actual table just the query results.

你似乎想要 select,而不是 update:

select 
    delete_field,
    case when delete_field = 'C' then 0 else ai_amount end as ai_amount,
    -- other columns here
from mytable