想知道是否有可能只保留一条记录以避免重复.在此场景中,ID也是重复的.我知道最好的方法是ID是唯一的,但在这个场景中不是.那么,我有三张这样的记录:
id | name | point | closest_community_id |
---|---|---|---|
1 | Secondary School | POINT (-121.94291423 49.17457331) | 126 |
1 | Secondary School | POINT (-121.94291423 49.17457331) | 126 |
1 | Secondary School | POINT (-121.94291423 49.17457331) | 126 |
我可以使用以下查询找到重复项:
select id, name, point, closest_community_id
from primary_location pl
group by pl.id, name, point, closest_community_id
having count(pl.id) > 1
但是,当重复项具有相同的ID时,我如何才能只保留一条记录呢?