Last active
September 25, 2019 14:03
-
-
Save godrix/f54b104e5a13bcd8f0bd731352f192ad to your computer and use it in GitHub Desktop.
Método Haversine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT *, (6371 * | |
acos( | |
cos(radians({{GEO.LAT}})) * | |
cos(radians(lat)) * | |
cos(radians({{GEO.LONG}}) - radians(lng)) + | |
sin(radians({{GEO.LAT}})) * | |
sin(radians(lat)) | |
)) AS distance | |
FROM tabela LOCATION distance <= {{RANGE.KM}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment