Skip to content

Instantly share code, notes, and snippets.

@speeddragon
Created February 13, 2019 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save speeddragon/1cbc733ac41493e677a4fa58e55225e9 to your computer and use it in GitHub Desktop.
Save speeddragon/1cbc733ac41493e677a4fa58e55225e9 to your computer and use it in GitHub Desktop.
SELECT id, ST_Distance_Sphere(ST_MakePoint(112.15769, 25.28552), r0."location") AS distance
FROM "restaurant" AS r0
WHERE ST_DWithin(ST_GeographyFromText('POINT(112.15769 25.28552)'), r0.location, 400)
ORDER BY distance
LIMIT 20 OFFSET 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment