Remove duplicate comparisons in postgres?

by user3052682   Last Updated October 15, 2018 08:06 AM

I have a polygon layer named scale_polygons_v4 I want to get ids of overlapping polygons I have tried the code below

select distinct s1.id,s2.id from scale_polygons_v4 s1 
inner join scale_polygons_v4 s2
on s1.id!=s2.id and s1.kind=s2.kind and st_overlaps(s1.geom,s2.geom)

results are fine but with duplicate comparisions e.g it returns

10029161,10011031
10011031,10029161

there are multiple such cases I only want to get one comparison

Tags : postgresql


Related Questions


Postgres gist slow index f_unaccent

Updated April 09, 2018 20:06 PM