俱乐部更新查询与组通过基于两个属性// postgres

俱乐部更新查询与组通过基于两个属性// postgres

问题描述:

如何更新基于两个属性由组派生的计数表?俱乐部更新查询与组通过基于两个属性// postgres

如: Thers其列的表A,B,C

我需要在此基础上有计数更新C++常用(A,B)

更新PostgreSQL有一个FROM extension你可以使用:

update YourTable as yt1 
set  c = case when aggr.cnt > 5 then 'Q' else 'Z' end 
from (
     select a 
     ,  b 
     ,  count(*) as cnt 
     from YourTable 
     group by 
       a 
     ,  b 
     ) as aggr 
where aggr.a = yt1.a 
     and aggr.b = yt1.b