Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (WITH closest_candidates AS (
- SELECT
- ent.id,
- ent.name,
- ent.geom
- FROM
- geo_data.etablissements ent
- WHERE ent.activite_principale = '1071C'
- ORDER BY
- ent.geom <->
- 'SRID=4326;POINT (5.4153978921979125 43.271437384501965)'::geometry
- LIMIT 10
- )
- SELECT id
- FROM closest_candidates
- ORDER BY
- ST_Distance(
- geom,
- 'SRID=4326;POINT (5.4153978921979125 43.271437384501965)'::geometry
- )
- LIMIT 1)
- UNION ALL
- (WITH closest_candidates AS (
- SELECT
- ent.id,
- ent.name,
- ent.geom
- FROM
- geo_data.etablissements ent
- WHERE ent.activite_principale = '4711D'
- ORDER BY
- ent.geom <->
- 'SRID=4326;POINT (5.4153978921979125 43.271437384501965)'::geometry
- LIMIT 10
- )
- SELECT id
- FROM closest_candidates
- ORDER BY
- ST_Distance(
- geom,
- 'SRID=4326;POINT (5.4153978921979125 43.271437384501965)'::geometry
- )
- LIMIT 1)
- -- UNION ALL
- -- [...] And so on...
- SELECT DISTINCT ON (a.activite_principale)
- a.activite_principale,
- a.id
- FROM geo_data.etablissements AS a
- WHERE a.activite_principale IN ('1071C', '4711D', <3rd>, <4th>, <5th>)
- ORDER BY a.activite_principale,
- a.geom <-> 'SRID=32632;POINT(363982.8087 5623158.5124)'::geometry
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement