Skip to content

Instantly share code, notes, and snippets.

@nurey
Created July 19, 2013 18:50
Show Gist options
  • Save nurey/6041463 to your computer and use it in GitHub Desktop.
Save nurey/6041463 to your computer and use it in GitHub Desktop.
SELECT "places".* FROM (
SELECT
*,
ST_Distance_Sphere(geom, 'SRID=4326;POINT(-79.3937393 43.6526704)') as distance
FROM places
ORDER by geom <#> 'SRID=4326;POINT(-79.3937393 43.6526704)' LIMIT 50
) AS places
WHERE "places"."place_category_id" = 10 ORDER BY distance ASC LIMIT 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment