[postgis-users] add group number to a group by clause

Olivier Leprêtre o.lepretre at gmail.com
Thu Jul 20 10:53:15 PDT 2017


Hi,

 

I have sets of points which are piled up by groups. I found how to show the
different groups with the query below but I didn't find how to add a group
number for each group. I tried with "over partition" but it seems that it's
not possible to partition with geom column.

 

Here is the query :

 

select o.nbre,d.code,d.numero,d.nomvoie,d.commune from

(select geom,count(*) as nbre from adress group by geom having count(*) >1)
as o,

         lateral (select * from adress) as d where st_within(o.geom,d.geom)

 

it returns the piled points preceded with piled points count.

 

3 pointa (3 piled points)

3 pointf

3 pointg

2 point1 (2 pp)

2 point2

4 pntw   (4 pp)

4 pntx

4 pnty

4 pntz

 

How can I add a group column like this ?

 

1        3 pointa

1        3 pointf

1        3 pointg

2        2 point1

2        2 point2

3        4 pntw

3        4 pntx

3        4 pnty

3        4 pntz

 

 

Thanks for any idea,

 

Olivier

 

 

 

 

 

 



---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20170720/aa2ffa43/attachment.html>


More information about the postgis-users mailing list