我有一个查询的数据查询结果。
select count(type_of_vegetation)as count,type_of_vegetation 
from tb_patrol 
group by type_of_vegetation如下所示:
count | type of vegetation    
1     | Semak Belukar, Pepohonan   
2     | Pakis, Sawit, Senduduk     
1     | Pakis, Sawit, Ilalang, Akasia   
49    | Sawit    
15    | Pakis, Karet   
17    | Semak Belukar我想将值小于15的“植被类型”的值更新为“其他”,但按植被类型列出条件组,如下例所示:
count | type of vegetation    
1     | Others   
2     | Others    
1     | Others
49    | Sawit
15    | Pakis, Karet
17    | Semak Belukar我使用postgres。
发布于 2017-12-09 09:01:55
使用子查询和IN操作符:
UPDATE tb_patrol 
SET type_of_vegetation = 'Other'
WHERE type_of_vegetation  IN (
   select type_of_vegetation 
   from tb_patrol 
   group by type_of_vegetation
   having count(type_of_vegetation) < 15
);https://stackoverflow.com/questions/47726946
复制相似问题