![](/img/trans.png)
[英]How to handle multiple lines in a where clause for an update query (BigQuery)
[英]Update Table with Aggregate function in where clause Bigquery
我有包含以下数据的 TableA
Name A B Final
Andy 1 1 2
Sam 1 0 2
我想编写一个更新查询,它将执行以下操作:
我的查询
Update TableA
Set A = Case when Final in (1,2) then 1 else 0 End
Set B = Case When Final = 2 then 1 else 0
where final in (1,2) and **final <> sum(A+B)**
由于我们不能在 update where 子句中使用聚合函数,所以我不确定如何做最后一部分。
查询应该只更新 Sam 的行。
谢谢你的帮助!
Update TableA
Set A = Case when Final in (1,2) then 1 else 0 End
Set B = Case When Final = 2 then 1 else 0
where final in (1,2) and final <> A+B
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.