Created
August 30, 2016 15:07
-
-
Save antoniodipinto/cae89efdd4b906011aba05aca38bdfc8 to your computer and use it in GitHub Desktop.
This query return the distance between two cordinates
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
#This query return the distance between two cordinates | |
SELECT *, | |
(((acos(sin((LATITUDE_VALUE*pi()/180)) * sin(('nome_colonna_latitudine'*pi()/180))+cos((LATITUDE_VALUE*pi()/180)) * cos(('nome_colonna_latitudine'*pi()/180)) * cos(((LONGITUDE_VALUE- 'nome_colonna_longitudine'e)*pi()/180))))*180/pi())*60*1.1515*1.609344) | |
as distance | |
FROM coordinates_table | |
ORDER BY distance ASC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment