Update table with IF statement from another table in Postgresql

Viewed 14

How can I do such query in PostgreSQL?

update table1 set column9 = 
sum(
(if sum(a=table2.a + a=table2.b + a=table2.c)>0 then 1 else 0),
(if sum(b=table2.a + b=table2.b + b=table2.c)>0 then 1 else 0),
(if sum(c=table2.a + c=table2.b + c=table2.c)>0 then 1 else 0)
    )
1 Answers
Related